Skip to content

Commit

Permalink
refactor: fix type issues in docs app
Browse files Browse the repository at this point in the history
  • Loading branch information
matyasf authored and HerrTopi committed Oct 24, 2023
1 parent 4550926 commit 90a3173
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 30 deletions.
1 change: 1 addition & 0 deletions packages/__docs__/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"lint": "ui-scripts lint",
"lint:fix": "ui-scripts lint --fix",
"build:scripts:ts": "tsc -b tsconfig.node.build.json",
"ts:check": "tsc -p tsconfig.build.json --noEmit --emitDeclarationOnly false",
"clean": "ui-scripts clean",
"createStatsFile": "mkdirp ./__build__ && webpack --profile --json > __build__/bundleStats.json",
"analyseStatsFile": "webpack-bundle-analyzer __build__/bundleStats.json"
Expand Down
2 changes: 1 addition & 1 deletion packages/__docs__/src/App/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class App extends Component<AppProps, AppState> {
static defaultProps = {
trayWidth: 300
}
_content?: HTMLDivElement
_content?: HTMLDivElement | null
_menuTrigger?: HTMLButtonElement
_mediaQueryListener?: ReturnType<typeof addMediaQueryMatchListener>
_defaultDocumentTitle?: string
Expand Down
2 changes: 1 addition & 1 deletion packages/__docs__/src/App/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import type {
MainIconsData,
MainDocsData,
ProcessedFile
} from '../../buildScripts/DataTypes'
} from '../../buildScripts/DataTypes.mts'

type AppOwnProps = {
trayWidth: number
Expand Down
2 changes: 1 addition & 1 deletion packages/__docs__/src/Document/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ import { ${importName} } from '${esPath}'
>
{this.renderDetails(doc)}
</Tabs.Panel>
{children.map((child, index) => (
{children.map((child: any, index: any) => (
<Tabs.Panel
renderTitle={child.title}
key={`${child.id}TabPanel`}
Expand Down
2 changes: 1 addition & 1 deletion packages/__docs__/src/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Header extends Component<HeaderProps> {
}

handleSelect = (
_e: React.MouseEvent<Element, MouseEvent>,
_e: React.MouseEvent<any>,
updated: (string | number | undefined)[]
) => {
const [selectedVersion] = updated
Expand Down
2 changes: 1 addition & 1 deletion packages/__docs__/src/Hero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ class Hero extends Component<HeroProps> {
<Button
withBackground={false}
color="primary-inverse"
renderIcon={IconGithubSolid}
renderIcon={IconGithubSolid as any}
href="https://github.com/instructure/instructure-ui"
size={bigScreen ? 'large' : 'medium'}
margin="0 x-small x-small 0"
Expand Down
5 changes: 2 additions & 3 deletions packages/__docs__/src/Methods/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ import { Table } from '@instructure/ui-table'
import { compileMarkdown } from '../compileMarkdown'
import type { MethodsProps } from './props'
import { propTypes, allowedProps } from './props'
import {
import type {
MethodParameter,
MethodReturn,
TypeDescriptor
// eslint-disable-next-line import/no-unresolved
} from '../../buildScripts/DataTypes'
} from '../../buildScripts/DataTypes.mts'

class Methods extends Component<MethodsProps> {
static propTypes = propTypes
Expand Down
3 changes: 2 additions & 1 deletion packages/__docs__/src/Preview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class Preview extends Component<PreviewProps, PreviewState> {
background: 'checkerboard'
}

static getDerivedStateFromProps(props: PreviewProps, state: PreviewState) {
// TODO investigate why any is needed here
static getDerivedStateFromProps(props: any, state: PreviewState) {
if (props.error) {
return {
...state,
Expand Down
7 changes: 4 additions & 3 deletions packages/__docs__/src/Preview/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import type {
} from '@instructure/shared-types'
import PropTypes from 'prop-types'
import type { ComponentStyle, WithStyleProps } from '@instructure/emotion'
// eslint-disable-next-line import/no-unresolved
import type { MainDocsData } from '../../buildScripts/DataTypes'

import type { MainDocsData } from '../../buildScripts/DataTypes.mts'

type PreviewOwnProps = {
code: string
Expand Down Expand Up @@ -93,7 +93,8 @@ const propTypes: PropValidators<PropKeys> = {
'none'
]),
themes: PropTypes.object,
themeKey: PropTypes.string
themeKey: PropTypes.string,
error: PropTypes.string
}
type PreviewState = {
error: string | null
Expand Down
2 changes: 1 addition & 1 deletion packages/__docs__/src/Preview/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const generateStyle = (
position: 'relative',
overflow: 'auto',

...backgroundVariants[background],
...backgroundVariants[background!],

...(fullscreen && {
position: 'fixed',
Expand Down
4 changes: 2 additions & 2 deletions packages/__docs__/src/Properties/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import type {
SimpleType,
TSFunctionSignatureType,
TypeDescriptor
} from '../../buildScripts/DataTypes'
} from '../../buildScripts/DataTypes.mts'

@withStyle(generateStyle, null)
class Properties extends Component<PropertiesProps> {
Expand Down Expand Up @@ -90,7 +90,7 @@ class Properties extends Component<PropertiesProps> {
<code>{name}</code>
</Table.Cell>
<Table.Cell>
<code>{this.renderTSType(prop.tsType)}</code>
<code>{this.renderTSType(prop.tsType!)}</code>
</Table.Cell>
<Table.Cell>{this.renderDefault(prop)}</Table.Cell>
<Table.Cell>{this.renderDescription(prop)}</Table.Cell>
Expand Down
4 changes: 2 additions & 2 deletions packages/__docs__/src/Properties/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import type { PropValidators } from '@instructure/shared-types'
import PropTypes from 'prop-types'
import type { ComponentStyle, WithStyleProps } from '@instructure/emotion'
// eslint-disable-next-line import/no-unresolved
import type { PropDescriptor } from '../../buildScripts/DataTypes'

import type { PropDescriptor } from '../../buildScripts/DataTypes.mts'

type PropertiesOwnProps = {
props: Record<string, PropDescriptor>
Expand Down
4 changes: 2 additions & 2 deletions packages/__docs__/src/Returns/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import { Table } from '@instructure/ui-table'
import { compileMarkdown } from '../compileMarkdown'

import type { ReturnsProps } from './props'
// eslint-disable-next-line import/no-unresolved
import type { JSDocFunctionReturns } from '../../buildScripts/DataTypes'

import type { JSDocFunctionReturns } from '../../buildScripts/DataTypes.mts'

class Returns extends Component<ReturnsProps> {
renderRows() {
Expand Down
4 changes: 2 additions & 2 deletions packages/__docs__/src/Returns/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/
import type { PropValidators } from '@instructure/shared-types'
import PropTypes from 'prop-types'
// eslint-disable-next-line import/no-unresolved
import type { JSDocFunctionReturns } from '../../buildScripts/DataTypes'

import type { JSDocFunctionReturns } from '../../buildScripts/DataTypes.mts'

type ReturnsOwnProps = {
types: JSDocFunctionReturns[]
Expand Down
7 changes: 0 additions & 7 deletions packages/__docs__/src/TableOfContents/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,11 @@ import React, { Component } from 'react'

import { canUseDOM, ownerDocument } from '@instructure/ui-dom-utils'

// TODO ESList erroneusly reports this figure out why
// eslint-disable-next-line import/no-unresolved
import { Link } from '@instructure/ui-link'
// eslint-disable-next-line import/no-unresolved
import { List } from '@instructure/ui-list'
// eslint-disable-next-line import/no-unresolved
import { View } from '@instructure/ui-view'
// eslint-disable-next-line import/no-unresolved
import { ToggleDetails } from '@instructure/ui-toggle-details'
// eslint-disable-next-line import/no-unresolved
import { instructure } from '@instructure/ui-themes'
// eslint-disable-next-line import/no-unresolved
import { InstUISettingsProvider } from '@instructure/emotion'
import type { SpacingValues } from '@instructure/emotion'

Expand Down
6 changes: 4 additions & 2 deletions packages/__docs__/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
"compilerOptions": {
"outDir": "./types",
"module": "CommonJS",
"composite": true
"composite": true,
"allowImportingTsExtensions": true
},
"include": [
"src/**/*",
"components.js",
"globals.js",
"buildScripts/DataTypes.mts"
"buildScripts/DataTypes.mts",
"buildScripts/samplemedia/placeholder-image.js"
],
"exclude": ["__build__/**/*"],
"references": [
Expand Down

0 comments on commit 90a3173

Please sign in to comment.