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 (