From 67cde87fd1cd67a08c11c16bbe7f0f552f1f59ed Mon Sep 17 00:00:00 2001 From: Christopher Allford <6451942+ObliviousHarmony@users.noreply.github.com> Date: Thu, 23 Mar 2023 18:02:20 -0700 Subject: [PATCH] Enforce Strict `@types` Dependencies (#37351) --- .syncpackrc | 13 +- package.json | 44 +- .../fix-typescript-package-isolation | 5 + packages/js/admin-e2e-tests/package.json | 2 +- packages/js/admin-e2e-tests/tsconfig.json | 6 +- .../fix-typescript-package-isolation | 5 + packages/js/admin-layout/package.json | 2 +- packages/js/admin-layout/tsconfig-cjs.json | 6 +- packages/js/admin-layout/tsconfig.json | 6 +- .../fix-typescript-package-isolation | 5 + packages/js/api/package.json | 4 +- packages/js/api/tsconfig.json | 6 +- .../fix-typescript-package-isolation | 5 + packages/js/components/jest.config.json | 2 +- packages/js/components/package.json | 3 +- .../src/experimental-tree-control/types.ts | 13 +- .../js/components/src/form/form-context.ts | 12 +- .../js/components/src/form/test/index.tsx | 24 +- packages/js/components/src/index.ts | 2 +- .../js/components/src/section/context.tsx | 2 +- .../js/components/src/sortable/sortable.tsx | 2 +- .../src/tree-select-control/control.js | 26 +- .../src/tree-select-control/index.js | 2 +- packages/js/components/src/utils.tsx | 2 +- packages/js/components/tsconfig-cjs.json | 6 +- packages/js/components/tsconfig.json | 7 +- .../fix-typescript-package-isolation | 5 + packages/js/csv-export/jest.config.json | 2 +- packages/js/csv-export/package.json | 4 +- packages/js/csv-export/tsconfig-cjs.json | 6 +- packages/js/csv-export/tsconfig.json | 7 +- .../fix-typescript-package-isolation | 5 + packages/js/currency/jest.config.json | 2 +- packages/js/currency/package.json | 3 +- packages/js/currency/tsconfig-cjs.json | 6 +- packages/js/currency/tsconfig.json | 6 +- .../fix-typescript-package-isolation | 5 + .../js/customer-effort-score/jest.config.json | 2 +- .../js/customer-effort-score/package.json | 3 +- .../customer-effort-score/tsconfig-cjs.json | 6 +- .../js/customer-effort-score/tsconfig.json | 6 +- .../fix-typescript-package-isolation | 5 + packages/js/data/jest.config.json | 2 +- packages/js/data/package.json | 4 +- packages/js/data/tsconfig-cjs.json | 6 +- packages/js/data/tsconfig.json | 6 +- .../fix-typescript-package-isolation | 5 + packages/js/date/jest.config.json | 2 +- packages/js/date/package.json | 4 +- packages/js/date/src/index.ts | 4 +- packages/js/date/tsconfig-cjs.json | 6 +- packages/js/date/tsconfig.json | 6 +- .../fix-typescript-package-isolation | 5 + .../package.json | 2 +- .../fix-typescript-package-isolation | 5 + packages/js/eslint-plugin/package.json | 2 +- .../fix-typescript-package-isolation | 5 + packages/js/experimental/jest.config.json | 2 +- packages/js/experimental/package.json | 3 +- packages/js/experimental/tsconfig-cjs.json | 6 +- packages/js/experimental/tsconfig.json | 6 +- .../fix-typescript-package-isolation | 5 + packages/js/explat/jest.config.json | 2 +- packages/js/explat/package.json | 5 +- packages/js/explat/tsconfig-cjs.json | 6 +- packages/js/explat/tsconfig.json | 6 +- .../{jest.config.js => jest-preset.js} | 0 packages/js/internal-js-tests/package.json | 3 +- .../js/internal-js-tests/tsconfig-cjs.json | 6 +- packages/js/internal-js-tests/tsconfig.json | 7 +- packages/js/internal-style-build/package.json | 2 +- .../fix-typescript-package-isolation | 5 + packages/js/navigation/jest.config.json | 2 +- packages/js/navigation/package.json | 3 +- packages/js/navigation/tsconfig-cjs.json | 6 +- packages/js/navigation/tsconfig.json | 6 +- packages/js/notices/package.json | 2 +- packages/js/notices/tsconfig-cjs.json | 6 +- packages/js/notices/tsconfig.json | 6 +- .../fix-typescript-package-isolation | 5 + packages/js/number/jest.config.json | 2 +- packages/js/number/package.json | 3 +- packages/js/number/tsconfig-cjs.json | 6 +- packages/js/number/tsconfig.json | 6 +- .../fix-typescript-package-isolation | 5 + packages/js/onboarding/package.json | 2 +- packages/js/onboarding/tsconfig-cjs.json | 6 +- packages/js/onboarding/tsconfig.json | 6 +- .../fix-typescript-package-isolation | 5 + packages/js/product-editor/jest.config.json | 2 +- packages/js/product-editor/package.json | 3 +- .../test/category-field.test.tsx | 16 +- .../hooks/use-validation/use-validation.ts | 4 +- .../src/utils/create-ordered-children.tsx | 2 +- .../src/utils/get-header-title.ts | 2 +- packages/js/product-editor/tsconfig-cjs.json | 6 +- packages/js/product-editor/tsconfig.json | 6 +- .../fix-typescript-package-isolation | 5 + packages/js/tracks/package.json | 2 +- packages/js/tracks/tsconfig-cjs.json | 6 +- packages/js/tracks/tsconfig.json | 6 +- packages/js/tsconfig-cjs.json | 2 +- packages/js/tsconfig.json | 5 +- .../woocommerce-admin/client/jest.config.js | 2 +- .../create-attribute-term-modal.tsx | 4 +- .../test/product-form-actions.spec.tsx | 4 +- .../client/utils/url-helpers.ts | 2 +- plugins/woocommerce-admin/package.json | 2 +- .../fix-typescript-package-isolation | 5 + plugins/woocommerce-beta-tester/package.json | 2 +- .../fix-typescript-package-isolation | 5 + .../woocommerce/client/legacy/package.json | 1 + plugins/woocommerce/package.json | 2 +- pnpm-lock.yaml | 6609 ++++++++--------- tools/cli-core/package.json | 2 +- tools/code-analyzer/package.json | 4 +- tools/monorepo-merge/package.json | 4 +- tools/package-release/package.json | 4 +- tools/release-posts/package.json | 4 +- tools/storybook/package.json | 2 +- tools/version-bump/package.json | 2 +- turbo.json | 22 +- 122 files changed, 3617 insertions(+), 3622 deletions(-) create mode 100644 packages/js/admin-e2e-tests/changelog/fix-typescript-package-isolation create mode 100644 packages/js/admin-layout/changelog/fix-typescript-package-isolation create mode 100644 packages/js/api/changelog/fix-typescript-package-isolation create mode 100644 packages/js/components/changelog/fix-typescript-package-isolation create mode 100644 packages/js/csv-export/changelog/fix-typescript-package-isolation create mode 100644 packages/js/currency/changelog/fix-typescript-package-isolation create mode 100644 packages/js/customer-effort-score/changelog/fix-typescript-package-isolation create mode 100644 packages/js/data/changelog/fix-typescript-package-isolation create mode 100644 packages/js/date/changelog/fix-typescript-package-isolation create mode 100644 packages/js/dependency-extraction-webpack-plugin/changelog/fix-typescript-package-isolation create mode 100644 packages/js/eslint-plugin/changelog/fix-typescript-package-isolation create mode 100644 packages/js/experimental/changelog/fix-typescript-package-isolation create mode 100644 packages/js/explat/changelog/fix-typescript-package-isolation rename packages/js/internal-js-tests/{jest.config.js => jest-preset.js} (100%) create mode 100644 packages/js/navigation/changelog/fix-typescript-package-isolation create mode 100644 packages/js/number/changelog/fix-typescript-package-isolation create mode 100644 packages/js/onboarding/changelog/fix-typescript-package-isolation create mode 100644 packages/js/product-editor/changelog/fix-typescript-package-isolation create mode 100644 packages/js/tracks/changelog/fix-typescript-package-isolation create mode 100644 plugins/woocommerce-beta-tester/changelog/fix-typescript-package-isolation create mode 100644 plugins/woocommerce/changelog/fix-typescript-package-isolation diff --git a/.syncpackrc b/.syncpackrc index 57c61d0a79a..832c6f62e33 100644 --- a/.syncpackrc +++ b/.syncpackrc @@ -1,6 +1,6 @@ { "dev": true, - "filter": "^(?:config|react|react-dom|eslint|typescript|@typescript-eslint|@types/react|@wordpress|@types/wordpress__components|postcss).*$", + "filter": "^(?:config|react|react-dom|eslint|typescript|@typescript-eslint|@types/react|@wordpress|@types/wordpress__components|postcss|@types/node).*$", "indent": "\t", "overrides": true, "peer": true, @@ -59,7 +59,7 @@ "packages": [ "**" ], - "pinVersion": "^4.8.3" + "pinVersion": "^4.9.5" }, { "dependencies": [ @@ -154,6 +154,15 @@ "**" ], "pinVersion": "^8.4.7" + }, + { + "dependencies": [ + "@types/node" + ], + "packages": [ + "**" + ], + "pinVersion": "^16.18.18" } ] } diff --git a/package.json b/package.json index 9e50a58b174..adb2745dd07 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,10 @@ "title": "WooCommerce Monorepo", "description": "Monorepo for the WooCommerce ecosystem", "homepage": "https://woocommerce.com/", + "engines": { + "node": "^16.13.1", + "pnpm": "^7.13.3" + }, "private": true, "repository": { "type": "git", @@ -25,41 +29,41 @@ "sync-dependencies": "pnpm exec syncpack -- fix-mismatches" }, "devDependencies": { - "@babel/preset-env": "^7.16.11", - "@babel/runtime": "^7.17.2", - "@types/node": "14.14.33", + "@babel/preset-env": "^7.20.2", + "@babel/runtime": "^7.21.0", + "@types/node": "^16.18.18", "@woocommerce/eslint-plugin": "workspace:*", "@wordpress/data": "wp-6.0", "@wordpress/eslint-plugin": "^11.1.0", - "@wordpress/prettier-config": "^1.1.1", - "babel-loader": "^8.2.3", + "@wordpress/prettier-config": "^1.4.0", + "babel-loader": "^8.3.0", "chalk": "^4.1.2", "copy-webpack-plugin": "^10.2.4", - "core-js": "^3.21.1", - "css-loader": "^6.7.0", - "glob": "^7.2.0", + "core-js": "^3.29.1", + "css-loader": "^6.7.3", + "glob": "^7.2.3", "husky": "^7.0.4", - "jest": "^27.3.1", - "lint-staged": "^12.3.7", + "jest": "^27.5.1", + "lint-staged": "^12.5.0", "mkdirp": "^1.0.4", - "moment": "^2.29.1", + "moment": "^2.29.4", "node-stream-zip": "^1.15.0", "postcss-loader": "^4.3.0", - "prettier": "npm:wp-prettier@^2.2.1-beta-1", - "regenerator-runtime": "^0.13.9", + "prettier": "npm:wp-prettier@^2.6.2", + "regenerator-runtime": "^0.13.11", "request": "^2.88.2", - "sass": "^1.49.9", - "sass-loader": "^10.2.1", + "sass": "^1.59.3", + "sass-loader": "^10.4.1", "syncpack": "^9.8.4", - "turbo": "^1.8.3", - "typescript": "^4.8.3", + "turbo": "^1.8.5", + "typescript": "^4.9.5", "url-loader": "^1.1.2", - "webpack": "^5.70.0" + "webpack": "^5.76.2" }, "dependencies": { "@babel/core": "7.12.9", - "@wordpress/babel-plugin-import-jsx-pragma": "^3.1.0", - "@wordpress/babel-preset-default": "^6.4.1", + "@wordpress/babel-plugin-import-jsx-pragma": "^3.2.0", + "@wordpress/babel-preset-default": "^6.17.0", "lodash": "^4.17.21", "wp-textdomain": "1.0.1" }, diff --git a/packages/js/admin-e2e-tests/changelog/fix-typescript-package-isolation b/packages/js/admin-e2e-tests/changelog/fix-typescript-package-isolation new file mode 100644 index 00000000000..2d087939231 --- /dev/null +++ b/packages/js/admin-e2e-tests/changelog/fix-typescript-package-isolation @@ -0,0 +1,5 @@ +Significance: patch +Type: dev +Comment: Configuration change only + + diff --git a/packages/js/admin-e2e-tests/package.json b/packages/js/admin-e2e-tests/package.json index 1b9b7e15791..39837afded8 100644 --- a/packages/js/admin-e2e-tests/package.json +++ b/packages/js/admin-e2e-tests/package.json @@ -50,7 +50,7 @@ "jest-mock-extended": "^1.0.18", "rimraf": "^3.0.2", "ts-jest": "^27.1.3", - "typescript": "^4.8.3" + "typescript": "^4.9.5" }, "publishConfig": { "access": "public" diff --git a/packages/js/admin-e2e-tests/tsconfig.json b/packages/js/admin-e2e-tests/tsconfig.json index 78a96e81323..ec5de0e407d 100644 --- a/packages/js/admin-e2e-tests/tsconfig.json +++ b/packages/js/admin-e2e-tests/tsconfig.json @@ -2,6 +2,10 @@ "extends": "../tsconfig.json", "compilerOptions": { "rootDir": "src", - "outDir": "build" + "outDir": "build", + "typeRoots": [ + "./typings", + "./node_modules/@types" + ] } } diff --git a/packages/js/admin-layout/changelog/fix-typescript-package-isolation b/packages/js/admin-layout/changelog/fix-typescript-package-isolation new file mode 100644 index 00000000000..2d087939231 --- /dev/null +++ b/packages/js/admin-layout/changelog/fix-typescript-package-isolation @@ -0,0 +1,5 @@ +Significance: patch +Type: dev +Comment: Configuration change only + + diff --git a/packages/js/admin-layout/package.json b/packages/js/admin-layout/package.json index 5b001e5aef1..946ee191af5 100644 --- a/packages/js/admin-layout/package.json +++ b/packages/js/admin-layout/package.json @@ -56,7 +56,7 @@ "react-dom": "^17.0.2", "sass-loader": "^10.2.1", "ts-jest": "^27.1.3", - "typescript": "^4.8.3", + "typescript": "^4.9.5", "webpack": "^5.70.0", "webpack-cli": "^3.3.12" }, diff --git a/packages/js/admin-layout/tsconfig-cjs.json b/packages/js/admin-layout/tsconfig-cjs.json index 035d2318baf..c8b5b6a6b96 100644 --- a/packages/js/admin-layout/tsconfig-cjs.json +++ b/packages/js/admin-layout/tsconfig-cjs.json @@ -1,6 +1,10 @@ { "extends": "../tsconfig-cjs", "compilerOptions": { - "outDir": "build" + "outDir": "build", + "typeRoots": [ + "./typings", + "./node_modules/@types" + ] } } diff --git a/packages/js/admin-layout/tsconfig.json b/packages/js/admin-layout/tsconfig.json index ea9f201d401..c5f351a60cc 100644 --- a/packages/js/admin-layout/tsconfig.json +++ b/packages/js/admin-layout/tsconfig.json @@ -5,6 +5,10 @@ "outDir": "build-module", "declaration": true, "declarationMap": true, - "declarationDir": "./build-types" + "declarationDir": "./build-types", + "typeRoots": [ + "./typings", + "./node_modules/@types" + ] } } diff --git a/packages/js/api/changelog/fix-typescript-package-isolation b/packages/js/api/changelog/fix-typescript-package-isolation new file mode 100644 index 00000000000..2d087939231 --- /dev/null +++ b/packages/js/api/changelog/fix-typescript-package-isolation @@ -0,0 +1,5 @@ +Significance: patch +Type: dev +Comment: Configuration change only + + diff --git a/packages/js/api/package.json b/packages/js/api/package.json index 20ed57cff6e..86a297df751 100644 --- a/packages/js/api/package.json +++ b/packages/js/api/package.json @@ -50,7 +50,7 @@ "devDependencies": { "@types/create-hmac": "1.1.0", "@types/jest": "^27.4.1", - "@types/node": "13.13.5", + "@types/node": "^16.18.18", "@typescript-eslint/eslint-plugin": "^5.54.0", "@typescript-eslint/parser": "^5.54.0", "@woocommerce/eslint-plugin": "workspace:*", @@ -58,7 +58,7 @@ "eslint": "^8.32.0", "jest": "^27", "ts-jest": "^27", - "typescript": "^4.8.3" + "typescript": "^4.9.5" }, "publishConfig": { "access": "public" diff --git a/packages/js/api/tsconfig.json b/packages/js/api/tsconfig.json index 8ef7d238961..0379fdd24a9 100644 --- a/packages/js/api/tsconfig.json +++ b/packages/js/api/tsconfig.json @@ -4,7 +4,11 @@ "types": [ "node", "jest", "axios", "create-hmac" ], "rootDir": "src", "outDir": "dist", - "target": "es5" + "target": "es5", + "typeRoots": [ + "./typings", + "./node_modules/@types" + ] }, "include": [ "src/" ] } diff --git a/packages/js/components/changelog/fix-typescript-package-isolation b/packages/js/components/changelog/fix-typescript-package-isolation new file mode 100644 index 00000000000..2d087939231 --- /dev/null +++ b/packages/js/components/changelog/fix-typescript-package-isolation @@ -0,0 +1,5 @@ +Significance: patch +Type: dev +Comment: Configuration change only + + diff --git a/packages/js/components/jest.config.json b/packages/js/components/jest.config.json index 91c0faef97f..3d8108048f6 100644 --- a/packages/js/components/jest.config.json +++ b/packages/js/components/jest.config.json @@ -1,4 +1,4 @@ { "rootDir": "./src", - "preset": "../../internal-js-tests/jest.config.js" + "preset": "../node_modules/@woocommerce/internal-js-tests/jest-preset.js" } diff --git a/packages/js/components/package.json b/packages/js/components/package.json index b30ad074359..136755fe61c 100644 --- a/packages/js/components/package.json +++ b/packages/js/components/package.json @@ -128,6 +128,7 @@ "@types/wordpress__viewport": "^2.5.4", "@woocommerce/eslint-plugin": "workspace:*", "@woocommerce/internal-style-build": "workspace:*", + "@woocommerce/internal-js-tests": "workspace:*", "@wordpress/browserslist-config": "wp-6.0", "@wordpress/scripts": "^12.6.1", "concurrently": "^7.0.0", @@ -141,7 +142,7 @@ "rimraf": "^3.0.2", "sass-loader": "^10.2.1", "ts-jest": "^27.1.3", - "typescript": "^4.8.3", + "typescript": "^4.9.5", "uuid": "^8.3.0", "webpack": "^5.70.0", "webpack-cli": "^3.3.12" diff --git a/packages/js/components/src/experimental-tree-control/types.ts b/packages/js/components/src/experimental-tree-control/types.ts index f97cb4ed58b..bc25193e58e 100644 --- a/packages/js/components/src/experimental-tree-control/types.ts +++ b/packages/js/components/src/experimental-tree-control/types.ts @@ -27,7 +27,7 @@ type BaseTreeProps = { * ancestors and its descendants are also selected. If it's false * only the clicked item is selected. * - * @param value The selection + * @param value The selection */ onSelect?( value: Item | Item[] ): void; /** @@ -36,7 +36,7 @@ type BaseTreeProps = { * are also unselected. If it's false only the clicked item is * unselected. * - * @param value The unselection + * @param value The unselection */ onRemove?( value: Item | Item[] ): void; /** @@ -48,8 +48,8 @@ type BaseTreeProps = { * shouldItemBeHighlighted={ isFirstChild } * /> * - * @param item The current linked tree item, useful to - * traverse the entire linked tree from this item. + * @param item The current linked tree item, useful to + * traverse the entire linked tree from this item. * * @see {@link LinkedTree} */ @@ -66,7 +66,8 @@ export type TreeProps = BaseTreeProps & > & { level?: number; items: LinkedTree[]; - /** It gives a way to render a different Element as the + /** + * It gives a way to render a different Element as the * tree item label. * * @example @@ -74,7 +75,7 @@ export type TreeProps = BaseTreeProps & * getItemLabel={ ( item ) => ${ item.data.label } } * /> * - * @param item The current rendering tree item + * @param item The current rendering tree item * * @see {@link LinkedTree} */ diff --git a/packages/js/components/src/form/form-context.ts b/packages/js/components/src/form/form-context.ts index 21c46f36e79..39c41eb8647 100644 --- a/packages/js/components/src/form/form-context.ts +++ b/packages/js/components/src/form/form-context.ts @@ -18,7 +18,7 @@ export type FormErrors< Values > = { }; // eslint-disable-next-line @typescript-eslint/no-explicit-any -export type FormContext< Values extends Record< string, any > > = { +export type FormContextType< Values extends Record< string, any > > = { values: Values; errors: FormErrors< Values >; isDirty: boolean; @@ -51,14 +51,16 @@ export type FormContext< Values extends Record< string, any > > = { }; // eslint-disable-next-line @typescript-eslint/no-explicit-any -export const FormContext = createContext< FormContext< any > >( +export const FormContext: React.Context< FormContextType< any > > = // eslint-disable-next-line @typescript-eslint/no-explicit-any - {} as FormContext< any > -); + createContext< FormContextType< any > >( + // eslint-disable-next-line @typescript-eslint/no-explicit-any + {} as FormContextType< any > + ); // eslint-disable-next-line @typescript-eslint/no-explicit-any export function useFormContext< Values extends Record< string, any > >() { - const formContext = useContext< FormContext< Values > >( FormContext ); + const formContext = useContext< FormContextType< Values > >( FormContext ); return formContext; } diff --git a/packages/js/components/src/form/test/index.tsx b/packages/js/components/src/form/test/index.tsx index daaae785b59..06f7bddd4ad 100644 --- a/packages/js/components/src/form/test/index.tsx +++ b/packages/js/components/src/form/test/index.tsx @@ -10,7 +10,7 @@ import { TextControl } from '@wordpress/components'; * Internal dependencies */ import { Form, useFormContext } from '../'; -import type { FormContext } from '../'; +import type { FormContextType } from '../'; import { DateTimePickerControl } from '../../date-time-picker-control'; const TestInputWithContext = () => { @@ -44,7 +44,7 @@ describe( 'Form', () => { > { ( { handleSubmit, - }: FormContext< Record< string, string > > ) => { + }: FormContextType< Record< string, string > > ) => { return ; } } @@ -71,7 +71,7 @@ describe( 'Form', () => { onChange={ mockOnChange } validate={ () => ( {} ) } > - { ( { setValue }: FormContext< Record< string, string > > ) => { + { ( { setValue }: FormContextType< Record< string, string > > ) => { return ( ; } } @@ -124,7 +124,7 @@ describe( 'Form', () => { const { queryByText } = render(
( {} ) }> - { ( { setValue }: FormContext< Record< string, string > > ) => { + { ( { setValue }: FormContextType< Record< string, string > > ) => { return (