From 2c8ac507c1800b1e3a0fa272d65bc2a03a34afb6 Mon Sep 17 00:00:00 2001 From: Lena Morita Date: Wed, 24 Aug 2022 20:58:34 +0900 Subject: [PATCH] Components: Invert tsconfig to be exclude-based (#43534) * Components: Invert tsconfig to be exclude-based * Update contributing guide --- packages/components/CONTRIBUTING.md | 4 +- packages/components/tsconfig.json | 127 +++++++++++----------------- 2 files changed, 53 insertions(+), 78 deletions(-) diff --git a/packages/components/CONTRIBUTING.md b/packages/components/CONTRIBUTING.md index ca8f948b7ee85..989fe32e8f491 100644 --- a/packages/components/CONTRIBUTING.md +++ b/packages/components/CONTRIBUTING.md @@ -480,7 +480,7 @@ component-family-name/ Given a component folder (e.g. `packages/components/src/unit-control`): -1. Add the folder to `tsconfig.json`, if it isn’t already. +1. Remove the folder from the exclude list in `tsconfig.json`, if it isn’t already. 2. Remove any `// @ts-nocheck` comments in the folder, if any. 3. Rename `*.js{x}` files to `*.ts{x}` (except stories and unit tests). 4. Run `npm run dev` and take note of all the errors (your IDE should also flag them). @@ -504,7 +504,7 @@ Given a component folder (e.g. `packages/components/src/unit-control`): } ``` - 3. Add the folders to the `tsconfig.json` file. + 3. Remove the folders from the exclude list in the `tsconfig.json` file. 4. If you’re still getting errors about a component’s props, the easiest way is to slightly refactor this component and perform the props destructuring inside the component’s body (as opposed as in the function signature) — this is to prevent TypeScript from inferring the types of these props. 5. Continue with the refactor of the current component (and take care of the refactor of the dependent components at a later stage). 6. Create a new `types.ts` file. diff --git a/packages/components/tsconfig.json b/packages/components/tsconfig.json index 0d63f0483fb49..2b292520a92be 100644 --- a/packages/components/tsconfig.json +++ b/packages/components/tsconfig.json @@ -30,80 +30,7 @@ { "path": "../react-i18n" }, { "path": "../warning" } ], - "include": [ - "src/__next/**/*", - "src/animate/**/*", - "src/base-control/**/*", - "src/base-field/**/*", - "src/border-box-control/**/*", - "src/border-control/**/*", - "src/button/**/*", - "src/button-group/**/*", - "src/card/**/*", - "src/checkbox-control/**/*", - "src/circular-option-picker/**/*", - "src/color-indicator/**/*", - "src/color-palette/**/*", - "src/color-picker/**/*", - "src/confirm-dialog/**/*", - "src/dashicon/**/*", - "src/date-time/**/*", - "src/disabled/**/*", - "src/divider/**/*", - "src/draggable/**/*", - "src/dropdown/**/*", - "src/dropdown-menu/**/*", - "src/elevation/**/*", - "src/external-link/**/*", - "src/flex/**/*", - "src/form-group/**/*", - "src/form-toggle/**/*", - "src/form-token-field/**/*", - "src/grid/**/*", - "src/h-stack/**/*", - "src/heading/**/*", - "src/higher-order/with-focus-outside/**/*", - "src/icon/**/*", - "src/input-control/**/*", - "src/item-group/**/*", - "src/menu-item/**/*", - "src/menu-group/**/*", - "src/modal/**/*", - "src/navigable-container/**/*", - "src/navigator/**/*", - "src/number-control/**/*", - "src/placeholder/**/*", - "src/popover/**/*", - "src/radio-control/**/*", - "src/range-control/**/*", - "src/resizable-box/**/*", - "src/scroll-lock/**/*", - "src/scrollable/**/*", - "src/select-control/**/*", - "src/shortcut/**/*", - "src/slot-fill/**/*", - "src/style-provider/**/*", - "src/spacer/**/*", - "src/spinner/**/*", - "src/surface/**/*", - "src/text/**/*", - "src/text-control/**/*", - "src/text-highlight/**/*", - "src/textarea-control/**/*", - "src/tip/**/*", - "src/toggle-group-control/**/*", - "src/tools-panel/**/*", - "src/tooltip/**/*", - "src/tree-select/**/*", - "src/truncate/**/*", - "src/ui/**/*", - "src/unit-control/**/*", - "src/utils/**/*", - "src/v-stack/**/*", - "src/view/**/*", - "src/visually-hidden/**/*", - "src/z-stack/**/*" - ], + "include": [ "src/**/*" ], "exclude": [ "src/**/*.android.js", "src/**/*.ios.js", @@ -111,7 +38,55 @@ "src/**/react-native-*", "src/**/stories/**.js", // only exclude js files, tsx files should be checked "src/**/test/**.js", // only exclude js files, ts{x} files should be checked - "src/ui/__storybook-utils", - "src/ui/font-size-control" + "src/index.js", + "src/alignment-matrix-control", + "src/angle-picker-control", + "src/autocomplete", + "src/box-control", + "src/clipboard-button", + "src/color-list-picker", + "src/combobox-control", + "src/custom-gradient-picker", + "src/custom-select-control", + "src/dimension-control", + "src/drop-zone", + "src/duotone-picker", + "src/focal-point-picker", + "src/focusable-iframe", + "src/font-size-picker", + "src/form-file-upload", + "src/gradient-picker", + "src/guide", + "src/higher-order/navigate-regions", + "src/higher-order/with-constrained-tabbing", + "src/higher-order/with-fallback-styles", + "src/higher-order/with-filters", + "src/higher-order/with-focus-return", + "src/higher-order/with-spoken-messages", + "src/higher-order/with-notices", + "src/isolated-event-container", + "src/keyboard-shortcuts", + "src/menu-items-choice", + "src/navigation", + "src/notice", + "src/palette-edit", + "src/panel", + "src/query-controls", + "src/radio", + "src/radio-group", + "src/responsive-wrapper", + "src/sandbox", + "src/search-control", + "src/snackbar", + "src/tab-panel", + "src/toggle-control", + "src/toolbar", + "src/toolbar-button", + "src/toolbar-context", + "src/toolbar-dropdown-menu", + "src/toolbar-group", + "src/toolbar-item", + "src/tree-grid", + "src/ui/__storybook-utils" ] }