Skip to content

Commit

Permalink
[NO_TICKET] Fix flag typing (#968)
Browse files Browse the repository at this point in the history
* Remove console.log

* Generate typescript definition files for tsx files, and rely on manual type defs for jsx
  • Loading branch information
bernardwang authored Mar 10, 2021
1 parent 5088d75 commit 1891293
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 102 deletions.
15 changes: 11 additions & 4 deletions packages/design-system-scripts/gulp/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,15 @@ async function copyAll(dir, options) {
*/
async function generateTypeDefinitions(dir, changedPath) {
const src = path.join(dir, 'src', 'components');
const srcGlob = getSrcGlob(src, changedPath);
const srcGlob = changedPath
? [changedPath`!${src}/**/*.{js,jsx}`]
: [
`${src}/**/*.{ts,tsx}`,
`!${src}/**/*.{js,jsx}`,
`!${src}/setupTests.{js,jsx,ts,tsx}`,
`!${src}/**/*{.test,.spec,.d}.{js,jsx,ts,tsx}`,
`!${src}/**/{__mocks__,__tests__,helpers}/**/*`,
];

const tsProject = ts.createProject('tsconfig.json', {
declaration: true,
Expand Down Expand Up @@ -174,9 +182,8 @@ function compileJs(dir, options, changedPath) {
return compileEsmJs(dir, changedPath);
})
.then(() => {
// If design system is using typescript, use tsc to generate definition files
// Core DS manually updates definition files
if (options.typescript && !options.core) {
// If design system is using typescript, use tsc to generate definition files for tsx files
if (options.typescript) {
return generateTypeDefinitions(dir, changedPath);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ module.exports = async function createReactExampleWebpackConfig(

const entry = [...(additionalEntry ? [exampleEntryFile] : []), path.resolve(reactExampleEntry)];

console.log(entry);

const config = {
mode: process.env.NODE_ENV,
entry,
Expand Down
86 changes: 0 additions & 86 deletions packages/design-system/src/types/FormControl/FormControl.d.ts

This file was deleted.

9 changes: 0 additions & 9 deletions packages/design-system/src/types/InlineError/InlineError.d.ts

This file was deleted.

7 changes: 6 additions & 1 deletion packages/design-system/src/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ export { default as TabPanel } from './Tabs/TabPanel';
export { default as TextField } from './TextField/TextField';
export { maskValue, unmaskValue } from './TextField/Mask';
export { default as UsaBanner } from './UsaBanner/UsaBanner';
export { default as VerticalNav } from './VerticalNav/VerticalNav';
export { default as VerticalNav } from './VerticalNav/VerticalNav';

// Type definitions generated by cmsds scripts
export * from './InlineError/InlineError';
export * from './FormControl/FormControl';
export * from './flags';

0 comments on commit 1891293

Please sign in to comment.