Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Fix build not including typescript types #2076

Merged
merged 3 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"test:serverside": "yarn build && node src/serverSideTest.js",
"storybook": "start-storybook -p 9009",
"storybook:deploy": "storybook-to-ghpages",
"build": "webpack --progress",
"build:watch": "webpack --watch",
"lint": "tsc --noEmit && eslint --ext js,jsx,ts,tsx src && stylelint \"src/**/*.{css,scss}\"",
"build": "tsc && webpack --progress",
"build:watch": "tsc && webpack --watch",
Comment on lines +30 to +31
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manually call tsc here so that types are built to lib

"lint": "tsc --noEmit --emitDeclarationOnly false && eslint --ext js,jsx,ts,tsx src && stylelint \"src/**/*.{css,scss}\"",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

noEmit cannot be used alongside emitDeclarationOnly (as of ts 3.8), which is now in tsconfig. So we have to set it to false here, which is the recommended workaround

"release": "standard-version -t ''",
"prepare": "yarn build",
"prepublishOnly": "yarn test && yarn lint",
Expand Down Expand Up @@ -127,7 +127,7 @@
},
"husky": {
"hooks": {
"pre-commit": "tsc --noEmit && lint-staged",
"pre-commit": "tsc --noEmit --emitDeclarationOnly false && lint-staged",
"pre-push": "yarn danger local -b main --failOnErrors"
}
},
Expand Down
15 changes: 9 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ export { Grid } from './components/grid/Grid/Grid'
/** Form components */
export { CharacterCount } from './components/forms/CharacterCount/CharacterCount'
export { Checkbox } from './components/forms/Checkbox/Checkbox'
export { ComboBox, ComboBoxOption } from './components/forms/ComboBox/ComboBox'
export { ComboBox } from './components/forms/ComboBox/ComboBox'
export type {
ComboBoxRef,
ComboBoxOption,
} from './components/forms/ComboBox/ComboBox'
export { DateInput } from './components/forms/DateInput/DateInput'
export { DateInputGroup } from './components/forms/DateInputGroup/DateInputGroup'
export { DatePicker } from './components/forms/DatePicker/DatePicker'
Expand All @@ -40,6 +44,7 @@ export { Dropdown } from './components/forms/Dropdown/Dropdown'
export { ErrorMessage } from './components/forms/ErrorMessage/ErrorMessage'
export { Fieldset } from './components/forms/Fieldset/Fieldset'
export { FileInput } from './components/forms/FileInput/FileInput'
export type { FileInputRef } from './components/forms/FileInput/FileInput'
export { Form } from './components/forms/Form/Form'
export { FormGroup } from './components/forms/FormGroup/FormGroup'
export { InputPrefix } from './components/forms/InputPrefix/InputPrefix'
Expand All @@ -65,7 +70,7 @@ export { NavDropDownButton } from './components/header/NavDropDownButton/NavDrop
export { PrimaryNav } from './components/header/PrimaryNav/PrimaryNav'
export { Title } from './components/header/Title/Title'

// IconList
/** IconList component */
export { IconList } from './components/IconList/IconList'
export { IconListItem } from './components/IconList/IconListItem/IconListItem'
export { IconListTitle } from './components/IconList/IconListTitle/IconListTitle'
Expand Down Expand Up @@ -93,11 +98,12 @@ export { Logo } from './components/Footer/Logo/Logo'
export { SocialLinks } from './components/Footer/SocialLinks/SocialLinks'

/** Modal components */
export { Modal, ModalProps, ModalRef } from './components/Modal/Modal'
export { Modal } from './components/Modal/Modal'
export { ModalToggleButton } from './components/Modal/ModalToggleButton'
export { ModalOpenLink } from './components/Modal/ModalOpenLink'
export { ModalHeading } from './components/Modal/ModalHeading/ModalHeading'
export { ModalFooter } from './components/Modal/ModalFooter/ModalFooter'
export type { ModalProps, ModalRef } from './components/Modal/Modal'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These export type changes silence some TS warnings we were getting on build


/** Card components */
export { CardGroup } from './components/card/CardGroup/CardGroup'
Expand Down Expand Up @@ -126,6 +132,3 @@ export { ProcessListItem } from './components/ProcessList/ProcessListItem/Proces
export { ProcessListHeading } from './components/ProcessList/ProcessListHeading/ProcessListHeading'

export { SiteAlert } from './components/SiteAlert/SiteAlert'

export type { FileInputRef } from './components/forms/FileInput/FileInput'
export type { ComboBoxRef } from './components/forms/ComboBox/ComboBox'
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"noEmit": true,
"emitDeclarationOnly": true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously, awesome-typescript-loader was exporting the types. Now we rely on tsc to do it, so we emit those type declarations only, and let babel emit the rest of the transpiled source code

"jsx": "react",
"noImplicitAny": true,
"declaration": true,
"outDir": "./lib"
"outDir": "./lib",
"isolatedModules": true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

},
"include": ["src/**/*", "custom.d.ts"],
"exclude": [
Expand Down