From d1ec2b8b10c0803ef4a7ad2b36deb110c8641fb3 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 26 Feb 2020 23:16:39 +0100 Subject: [PATCH 01/65] Add tsconfigs for packages --- packages/a11y/package.json | 1 + packages/a11y/tsconfig.json | 8 ++++++ packages/blob/package.json | 1 + packages/blob/tsconfig.json | 7 +++++ packages/dom-ready/package.json | 1 + packages/dom-ready/tsconfig.json | 7 +++++ packages/i18n/package.json | 1 + packages/i18n/tsconfig.json | 7 +++++ packages/is-shallow-equal/package.json | 1 + packages/is-shallow-equal/tsconfig.json | 8 ++++++ packages/priority-queue/package.json | 1 + packages/priority-queue/tsconfig.json | 7 +++++ packages/token-list/package.json | 1 + packages/token-list/tsconfig.json | 7 +++++ packages/url/package.json | 1 + packages/url/tsconfig.json | 7 +++++ packages/warning/package.json | 1 + packages/warning/tsconfig.json | 7 +++++ tsconfig.base.json | 34 +++++++++++++++++++++++++ 19 files changed, 108 insertions(+) create mode 100644 packages/a11y/tsconfig.json create mode 100644 packages/blob/tsconfig.json create mode 100644 packages/dom-ready/tsconfig.json create mode 100644 packages/i18n/tsconfig.json create mode 100644 packages/is-shallow-equal/tsconfig.json create mode 100644 packages/priority-queue/tsconfig.json create mode 100644 packages/token-list/tsconfig.json create mode 100644 packages/url/tsconfig.json create mode 100644 packages/warning/tsconfig.json create mode 100644 tsconfig.base.json diff --git a/packages/a11y/package.json b/packages/a11y/package.json index 3f2dc80ae2090..800fbeee1c28d 100644 --- a/packages/a11y/package.json +++ b/packages/a11y/package.json @@ -21,6 +21,7 @@ "main": "build/index.js", "module": "build-module/index.js", "react-native": "src/index", + "types": "build-types", "dependencies": { "@babel/runtime": "^7.8.3", "@wordpress/dom-ready": "file:../dom-ready" diff --git a/packages/a11y/tsconfig.json b/packages/a11y/tsconfig.json new file mode 100644 index 0000000000000..0a7b3b271d031 --- /dev/null +++ b/packages/a11y/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build-types" + }, + "references": [ { "path": "../dom-ready" } ] +} diff --git a/packages/blob/package.json b/packages/blob/package.json index 86a19462a1e21..238b7cfcd8827 100644 --- a/packages/blob/package.json +++ b/packages/blob/package.json @@ -20,6 +20,7 @@ "main": "build/index.js", "module": "build-module/index.js", "react-native": "src/index", + "types": "build-types", "sideEffects": false, "dependencies": { "@babel/runtime": "^7.8.3" diff --git a/packages/blob/tsconfig.json b/packages/blob/tsconfig.json new file mode 100644 index 0000000000000..d90adc79f2afd --- /dev/null +++ b/packages/blob/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build-types" + } +} diff --git a/packages/dom-ready/package.json b/packages/dom-ready/package.json index 6fd51bdd0b714..422e0e8376b4d 100644 --- a/packages/dom-ready/package.json +++ b/packages/dom-ready/package.json @@ -20,6 +20,7 @@ "main": "build/index.js", "module": "build-module/index.js", "react-native": "src/index", + "types": "build-types", "sideEffects": false, "dependencies": { "@babel/runtime": "^7.8.3" diff --git a/packages/dom-ready/tsconfig.json b/packages/dom-ready/tsconfig.json new file mode 100644 index 0000000000000..d90adc79f2afd --- /dev/null +++ b/packages/dom-ready/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build-types" + } +} diff --git a/packages/i18n/package.json b/packages/i18n/package.json index a328ecf0959d0..ce5ef62a0b654 100644 --- a/packages/i18n/package.json +++ b/packages/i18n/package.json @@ -20,6 +20,7 @@ "main": "build/index.js", "module": "build-module/index.js", "react-native": "src/index", + "types": "build-types", "bin": { "pot-to-php": "./tools/pot-to-php.js" }, diff --git a/packages/i18n/tsconfig.json b/packages/i18n/tsconfig.json new file mode 100644 index 0000000000000..d90adc79f2afd --- /dev/null +++ b/packages/i18n/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build-types" + } +} diff --git a/packages/is-shallow-equal/package.json b/packages/is-shallow-equal/package.json index 0800bdb4e7543..dd36895545e34 100644 --- a/packages/is-shallow-equal/package.json +++ b/packages/is-shallow-equal/package.json @@ -25,6 +25,7 @@ "objects.js" ], "main": "index.js", + "types": "build-types", "sideEffects": false, "dependencies": { "@babel/runtime": "^7.8.3" diff --git a/packages/is-shallow-equal/tsconfig.json b/packages/is-shallow-equal/tsconfig.json new file mode 100644 index 0000000000000..ad64617326195 --- /dev/null +++ b/packages/is-shallow-equal/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": ".", + "outDir": "build-types" + }, + "files": [ "arrays.js", "index.js", "objects.js" ] +} diff --git a/packages/priority-queue/package.json b/packages/priority-queue/package.json index 955bbbd161f18..8e18f3158c896 100644 --- a/packages/priority-queue/package.json +++ b/packages/priority-queue/package.json @@ -21,6 +21,7 @@ "main": "build/index.js", "module": "build-module/index.js", "react-native": "src/index", + "types": "build-types", "sideEffects": false, "dependencies": { "@babel/runtime": "^7.8.3" diff --git a/packages/priority-queue/tsconfig.json b/packages/priority-queue/tsconfig.json new file mode 100644 index 0000000000000..d90adc79f2afd --- /dev/null +++ b/packages/priority-queue/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build-types" + } +} diff --git a/packages/token-list/package.json b/packages/token-list/package.json index 2e7947df9e8f5..65aaa92b9a718 100644 --- a/packages/token-list/package.json +++ b/packages/token-list/package.json @@ -19,6 +19,7 @@ "main": "build/index.js", "module": "build-module/index.js", "react-native": "src/index", + "types": "build-types", "dependencies": { "@babel/runtime": "^7.8.3", "lodash": "^4.17.15" diff --git a/packages/token-list/tsconfig.json b/packages/token-list/tsconfig.json new file mode 100644 index 0000000000000..d90adc79f2afd --- /dev/null +++ b/packages/token-list/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build-types" + } +} diff --git a/packages/url/package.json b/packages/url/package.json index c564a35d316e1..23417710b2ffc 100644 --- a/packages/url/package.json +++ b/packages/url/package.json @@ -20,6 +20,7 @@ "main": "build/index.js", "module": "build-module/index.js", "react-native": "src/index", + "types": "build-types", "sideEffects": false, "dependencies": { "@babel/runtime": "^7.8.3", diff --git a/packages/url/tsconfig.json b/packages/url/tsconfig.json new file mode 100644 index 0000000000000..d90adc79f2afd --- /dev/null +++ b/packages/url/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build-types" + } +} diff --git a/packages/warning/package.json b/packages/warning/package.json index fd94779db9e83..ebe83bb4221e6 100644 --- a/packages/warning/package.json +++ b/packages/warning/package.json @@ -20,6 +20,7 @@ "main": "build/index.js", "module": "build-module/index.js", "react-native": "src/index", + "types": "build-types", "sideEffects": false, "publishConfig": { "access": "public" diff --git a/packages/warning/tsconfig.json b/packages/warning/tsconfig.json new file mode 100644 index 0000000000000..d90adc79f2afd --- /dev/null +++ b/packages/warning/tsconfig.json @@ -0,0 +1,7 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "src", + "outDir": "build-types" + } +} diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000000000..1c0f4716921b4 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,34 @@ +{ + "compilerOptions": { + "allowJs": true, + "checkJs": true, + "allowSyntheticDefaultImports": true, + "jsx": "preserve", + "target": "esnext", + "module": "esnext", + "lib": [ "dom", "esnext" ], + "declaration": true, + "declarationMap": true, + "composite": true, + "emitDeclarationOnly": true, + // "isolatedModules": true, + + /* Strict Type-Checking Options */ + "strict": true /* Enable all strict type-checking options. */, + "strictNullChecks": true, + "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, + + /* Additional Checks */ + "noUnusedLocals": true, + "noUnusedParameters": true, + "noImplicitReturns": true, + "noFallthroughCasesInSwitch": true, + + /* Module Resolution Options */ + "moduleResolution": "node", + /* This needs to be false so our types are possible to consume without setting this */ + "esModuleInterop": false, + "resolveJsonModule": true + }, + "exclude": [ "**/benchmark", "**/test/**", "**/build/**", "**/build-*/**" ] +} From 38814d028780209dd11c931b893991d65cc6072f Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 26 Feb 2020 23:17:28 +0100 Subject: [PATCH 02/65] Update TypeScript package --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index a4184598a1d89..cc3229fb2e86c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39838,9 +39838,9 @@ "dev": true }, "typescript": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz", - "integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==", + "version": "3.8.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.2.tgz", + "integrity": "sha512-EgOVgL/4xfVrCMbhYKUQTdF37SQn4Iw73H5BgCrF1Abdun7Kwy/QZsE/ssAy0y4LxBbvua3PIbFsbRczWWnDdQ==", "dev": true }, "ua-parser-js": { diff --git a/package.json b/package.json index 61b182e0a1f67..d1f804e0d7cb9 100644 --- a/package.json +++ b/package.json @@ -167,7 +167,7 @@ "sprintf-js": "1.1.1", "style-loader": "1.0.0", "stylelint-config-wordpress": "13.1.0", - "typescript": "3.5.3", + "typescript": "3.8.2", "uuid": "3.3.2", "webpack": "4.42.0", "worker-farm": "1.7.0" From 9c238dd08be9a78871956dbff70c1f9cc1c3377d Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 26 Feb 2020 23:24:54 +0100 Subject: [PATCH 03/65] Add types --- package-lock.json | 12 ++++++++++++ package.json | 2 ++ 2 files changed, 14 insertions(+) diff --git a/package-lock.json b/package-lock.json index cc3229fb2e86c..d22792187f9d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10052,6 +10052,12 @@ "integrity": "sha512-Il2DtDVRGDcqjDtE+rF8iqg1CArehSK84HZJCT7AMITlyXRBpuPhqGLDQMowraqqu1coEaimg4ZOqggt6L6L+A==", "dev": true }, + "@types/lodash": { + "version": "4.14.149", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.149.tgz", + "integrity": "sha512-ijGqzZt/b7BfzcK9vTrS6MFljQRPn5BFWOx8oE0GYxribu6uV+aA9zZuXI1zc/etK9E8nrgdoF2+LgUw7+9tJQ==", + "dev": true + }, "@types/minimatch": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", @@ -10087,6 +10093,12 @@ "integrity": "sha512-ce5d3q03Ex0sy4R14722Rmt6MT07Ua+k4FwDfdcToYJcMKNtRVQvJ6JCAPdAmAnbRb6CsX6aYb9m96NGod9uTw==", "dev": true }, + "@types/qs": { + "version": "6.9.1", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.1.tgz", + "integrity": "sha512-lhbQXx9HKZAPgBkISrBcmAcMpZsmpe/Cd/hY7LGZS5OfkySUBItnPZHgQPssWYUET8elF+yCFBbP1Q0RZPTdaw==", + "dev": true + }, "@types/reach__router": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@types/reach__router/-/reach__router-1.2.6.tgz", diff --git a/package.json b/package.json index d1f804e0d7cb9..51d03e50bc2b1 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,8 @@ "@storybook/addon-viewport": "5.3.2", "@storybook/react": "5.3.2", "@types/jest": "24.0.25", + "@types/lodash": "4.14.149", + "@types/qs": "6.9.1", "@types/requestidlecallback": "0.3.1", "@wordpress/babel-plugin-import-jsx-pragma": "file:packages/babel-plugin-import-jsx-pragma", "@wordpress/babel-plugin-makepot": "file:packages/babel-plugin-makepot", From d6c5808f9c32ee6e066b097dcbcb7ea53a2e6905 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 26 Feb 2020 23:25:48 +0100 Subject: [PATCH 04/65] Gitignore types output --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index fc31278c325de..9520a90404511 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ build build-module build-style +build-types node_modules gutenberg.zip From 152ce84f297cc972e8b065911a581172587571b8 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 26 Feb 2020 23:26:48 +0100 Subject: [PATCH 05/65] Clean build-types --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 51d03e50bc2b1..04c169a4877f3 100644 --- a/package.json +++ b/package.json @@ -176,7 +176,7 @@ }, "scripts": { "prebuild": "npm run check-engines", - "clean:packages": "rimraf ./packages/*/build ./packages/*/build-module ./packages/*/build-style ./packages/*/node_modules", + "clean:packages": "rimraf ./packages/*/build ./packages/*/build-module ./packages/*/build-style ./packages/*/build-style ./packages/*/node_modules", "prebuild:packages": "npm run clean:packages && lerna run build", "build:packages": "node ./bin/packages/build.js", "build": "npm run build:packages && wp-scripts build", From cd066a3855f5c76c70c54043b296f5c4dd610f96 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 09:11:39 +0100 Subject: [PATCH 06/65] Add missing Parameters utility type --- packages/eslint-plugin/configs/jsdoc.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eslint-plugin/configs/jsdoc.js b/packages/eslint-plugin/configs/jsdoc.js index ca3ae01de8d4c..8bff4a36b7d32 100644 --- a/packages/eslint-plugin/configs/jsdoc.js +++ b/packages/eslint-plugin/configs/jsdoc.js @@ -47,6 +47,7 @@ const typescriptUtilityTypes = [ 'IterableIterator', 'NonNullable', 'Omit', + 'Parameters', 'Partial', 'Pick', 'PromiseLike', From 48cf167f59ddc7e0daeb39f91d435acd8956788f Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 10:00:06 +0100 Subject: [PATCH 07/65] Fix PriorityQueue types --- packages/priority-queue/src/index.js | 2 -- packages/priority-queue/src/request-idle-callback.js | 6 +++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/priority-queue/src/index.js b/packages/priority-queue/src/index.js index de82a4296e947..560ca7b5f4a3e 100644 --- a/packages/priority-queue/src/index.js +++ b/packages/priority-queue/src/index.js @@ -71,8 +71,6 @@ export const createQueue = () => { /** * Callback to process as much queue as time permits. * - * @type {IdleRequestCallback & FrameRequestCallback} - * * @param {IdleDeadline|number} deadline Idle callback deadline object, or * animation frame timestamp. */ diff --git a/packages/priority-queue/src/request-idle-callback.js b/packages/priority-queue/src/request-idle-callback.js index b147c9ad86638..64b51e7d2b336 100644 --- a/packages/priority-queue/src/request-idle-callback.js +++ b/packages/priority-queue/src/request-idle-callback.js @@ -1,5 +1,9 @@ /** - * @return {typeof window.requestIdleCallback|typeof window.requestAnimationFrame|((callback:(timestamp:number)=>void)=>void)} RequestIdleCallback + * @typedef {( timeOrDeadline: IdleDeadline | number ) => void} Callback + */ + +/** + * @return {(callback: Callback) => void} RequestIdleCallback */ export function createRequestIdleCallback() { if ( typeof window === 'undefined' ) { From d970cb3111ca6ecc3c51583a5c557adf4a6bdfd0 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 10:16:48 +0100 Subject: [PATCH 08/65] Add sprintf-js types --- package-lock.json | 6 ++++++ package.json | 1 + 2 files changed, 7 insertions(+) diff --git a/package-lock.json b/package-lock.json index d22792187f9d1..cbe6b43848eaa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10152,6 +10152,12 @@ "integrity": "sha512-BnnRkgWYijCIndUn+LgoqKHX/hNpJC5G03B9y7mZya/C2gUQTSn75fEj3ZP1/Rl2E6EYeXh2/7/8UNEZ4X7HuQ==", "dev": true }, + "@types/sprintf-js": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@types/sprintf-js/-/sprintf-js-1.1.2.tgz", + "integrity": "sha512-hkgzYF+qnIl8uTO8rmUSVSfQ8BIfMXC4yJAF4n8BE758YsKBZvFC4NumnAegj7KmylP0liEZNpb9RRGFMbFejA==", + "dev": true + }, "@types/stack-utils": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz", diff --git a/package.json b/package.json index 04c169a4877f3..cea1eac964d9d 100644 --- a/package.json +++ b/package.json @@ -89,6 +89,7 @@ "@types/lodash": "4.14.149", "@types/qs": "6.9.1", "@types/requestidlecallback": "0.3.1", + "@types/sprintf-js": "1.1.2", "@wordpress/babel-plugin-import-jsx-pragma": "file:packages/babel-plugin-import-jsx-pragma", "@wordpress/babel-plugin-makepot": "file:packages/babel-plugin-makepot", "@wordpress/babel-preset-default": "file:packages/babel-preset-default", From 62d202342959d4cd5869af488a972d75d0af82f3 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 10:17:12 +0100 Subject: [PATCH 09/65] Type plural_forms function --- packages/i18n/src/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/i18n/src/index.js b/packages/i18n/src/index.js index aa7a2d059f8a6..111ea03e55571 100644 --- a/packages/i18n/src/index.js +++ b/packages/i18n/src/index.js @@ -17,7 +17,10 @@ import sprintfjs from 'sprintf-js'; */ const DEFAULT_LOCALE_DATA = { '': { - plural_forms: ( n ) => ( n === 1 ? 0 : 1 ), + /** @param {number} n */ + plural_forms( n ) { + return n === 1 ? 0 : 1; + }, }, }; From 86451708d75ed2e24dcc2bb9a27914a1b6389e03 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 10:18:49 +0100 Subject: [PATCH 10/65] Allow i18n implicit any for untyped dependencies --- packages/i18n/tsconfig.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/i18n/tsconfig.json b/packages/i18n/tsconfig.json index d90adc79f2afd..2bb8ef02fd84b 100644 --- a/packages/i18n/tsconfig.json +++ b/packages/i18n/tsconfig.json @@ -1,7 +1,9 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { + "noImplicitAny": false, "rootDir": "src", "outDir": "build-types" - } + }, + "include": [ "src/**/*.js" ] } From 77c38354bf3d7d19e6a07081487345cadee685de Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 10:20:47 +0100 Subject: [PATCH 11/65] Add include --- packages/warning/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/warning/tsconfig.json b/packages/warning/tsconfig.json index d90adc79f2afd..04130a234cf55 100644 --- a/packages/warning/tsconfig.json +++ b/packages/warning/tsconfig.json @@ -3,5 +3,6 @@ "compilerOptions": { "rootDir": "src", "outDir": "build-types" - } + }, + "include": [ "src/**/*.js" ] } From fb52ceede12b5eb963f5556d281352c66e31fc07 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 11:05:00 +0100 Subject: [PATCH 12/65] Add tsbuildinfo locations --- packages/a11y/tsconfig.json | 3 ++- packages/blob/tsconfig.json | 3 ++- packages/dom-ready/tsconfig.json | 3 ++- packages/i18n/tsconfig.json | 3 ++- packages/is-shallow-equal/tsconfig.json | 3 ++- packages/priority-queue/tsconfig.json | 3 ++- packages/token-list/tsconfig.json | 3 ++- packages/url/tsconfig.json | 3 ++- packages/warning/tsconfig.json | 3 ++- 9 files changed, 18 insertions(+), 9 deletions(-) diff --git a/packages/a11y/tsconfig.json b/packages/a11y/tsconfig.json index 0a7b3b271d031..3f90daf8d02e2 100644 --- a/packages/a11y/tsconfig.json +++ b/packages/a11y/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types" + "outDir": "build-types", + "tsBuildInfoFile": "../../.cache/a11y.tsbuildinfo" }, "references": [ { "path": "../dom-ready" } ] } diff --git a/packages/blob/tsconfig.json b/packages/blob/tsconfig.json index d90adc79f2afd..ee67cda5160dc 100644 --- a/packages/blob/tsconfig.json +++ b/packages/blob/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types" + "outDir": "build-types", + "tsBuildInfoFile": "../../.cache/blob.tsbuildinfo" } } diff --git a/packages/dom-ready/tsconfig.json b/packages/dom-ready/tsconfig.json index d90adc79f2afd..8832a734adb53 100644 --- a/packages/dom-ready/tsconfig.json +++ b/packages/dom-ready/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types" + "outDir": "build-types", + "tsBuildInfoFile": "../../.cache/dom-ready.tsbuildinfo" } } diff --git a/packages/i18n/tsconfig.json b/packages/i18n/tsconfig.json index 2bb8ef02fd84b..d732484ff9d86 100644 --- a/packages/i18n/tsconfig.json +++ b/packages/i18n/tsconfig.json @@ -3,7 +3,8 @@ "compilerOptions": { "noImplicitAny": false, "rootDir": "src", - "outDir": "build-types" + "outDir": "build-types", + "tsBuildInfoFile": "../../.cache/i18n.tsbuildinfo" }, "include": [ "src/**/*.js" ] } diff --git a/packages/is-shallow-equal/tsconfig.json b/packages/is-shallow-equal/tsconfig.json index ad64617326195..cd65275ffa019 100644 --- a/packages/is-shallow-equal/tsconfig.json +++ b/packages/is-shallow-equal/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": ".", - "outDir": "build-types" + "outDir": "build-types", + "tsBuildInfoFile": "../../.cache/is-shallow-equal.tsbuildinfo" }, "files": [ "arrays.js", "index.js", "objects.js" ] } diff --git a/packages/priority-queue/tsconfig.json b/packages/priority-queue/tsconfig.json index d90adc79f2afd..8387bbe84cecc 100644 --- a/packages/priority-queue/tsconfig.json +++ b/packages/priority-queue/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types" + "outDir": "build-types", + "tsBuildInfoFile": "../../.cache/priority-queue.tsbuildinfo" } } diff --git a/packages/token-list/tsconfig.json b/packages/token-list/tsconfig.json index d90adc79f2afd..a210dc6cd5989 100644 --- a/packages/token-list/tsconfig.json +++ b/packages/token-list/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types" + "outDir": "build-types", + "tsBuildInfoFile": "../../.cache/token-list.tsbuildinfo" } } diff --git a/packages/url/tsconfig.json b/packages/url/tsconfig.json index d90adc79f2afd..f71a7c9817166 100644 --- a/packages/url/tsconfig.json +++ b/packages/url/tsconfig.json @@ -2,6 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types" + "outDir": "build-types", + "tsBuildInfoFile": "../../.cache/url.tsbuildinfo" } } diff --git a/packages/warning/tsconfig.json b/packages/warning/tsconfig.json index 04130a234cf55..ab43cdf9bdb9a 100644 --- a/packages/warning/tsconfig.json +++ b/packages/warning/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types" + "outDir": "build-types", + "tsBuildInfoFile": "../../.cache/warning.tsbuildinfo" }, "include": [ "src/**/*.js" ] } From 124a8b30ad82739d5104df151368c6dfe948f654 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 16:44:03 +0100 Subject: [PATCH 13/65] Clean the right directories --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cea1eac964d9d..59eb7a6020a7c 100644 --- a/package.json +++ b/package.json @@ -177,7 +177,7 @@ }, "scripts": { "prebuild": "npm run check-engines", - "clean:packages": "rimraf ./packages/*/build ./packages/*/build-module ./packages/*/build-style ./packages/*/build-style ./packages/*/node_modules", + "clean:packages": "rimraf ./packages/*/build ./packages/*/build-* ./.cache/*.tsbuildinfo ./packages/*/node_modules", "prebuild:packages": "npm run clean:packages && lerna run build", "build:packages": "node ./bin/packages/build.js", "build": "npm run build:packages && wp-scripts build", From fcbff69d4d15259aa76a957a17cdc943c8622223 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 18:29:10 +0100 Subject: [PATCH 14/65] Remove root tsconfig --- tsconfig.json | 52 --------------------------------------------------- 1 file changed, 52 deletions(-) delete mode 100644 tsconfig.json diff --git a/tsconfig.json b/tsconfig.json deleted file mode 100644 index d470e66c01e3c..0000000000000 --- a/tsconfig.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "compilerOptions": { - "allowJs": true, - "allowSyntheticDefaultImports": true, - "checkJs": true, - "jsx": "preserve", - "lib": ["dom", "esnext", "es2020.string"], - "module": "commonjs", - "noEmit": true, - "resolveJsonModule": true, - "target": "esnext", - - /* Project Imports */ - "baseUrl": ".", - "paths": { - "@wordpress/*": [ - "packages/*/index.js", - "packages/*/src/index.js" - ] - }, - - /* Strict Type-Checking Options */ - "strict": true, /* Enable all strict type-checking options. */ - "strictNullChecks": true, - "noImplicitAny": false, /* Raise error on expressions and declarations with an implied 'any' type. */ - - /* Additional Checks */ - "noUnusedLocals": true, /* Report errors on unused locals. */ - "noUnusedParameters": true, /* Report errors on unused parameters. */ - "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ - "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ - }, - "include": [ - "./bin/api-docs/update-api-docs.js", - "./packages/a11y/**/*.js", - "./packages/blob/**/*.js", - "./packages/dom-ready/**/*.js", - "./packages/i18n/**/*.js", - "./packages/is-shallow-equal/**/*.js", - "./packages/priority-queue/**/*.js", - "./packages/project-management-automation/**/*.js", - "./packages/token-list/**/*.js", - "./packages/url/src/**/*.js", - "./packages/warning/**/*.js", - ], - "exclude": [ - "./packages/*/benchmark", - "./packages/**/test/**", - "./packages/**/build/**", - "./packages/**/build-module/**" - ] -} From eb26707e062d0db45b48008c15b2675b311d835f Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 18:31:55 +0100 Subject: [PATCH 15/65] Add build-types --- bin/packages/build-types.js | 38 +++++++++++++++++++++++++++++++++++++ package.json | 4 ++-- 2 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 bin/packages/build-types.js diff --git a/bin/packages/build-types.js b/bin/packages/build-types.js new file mode 100644 index 0000000000000..7fcb153601cc1 --- /dev/null +++ b/bin/packages/build-types.js @@ -0,0 +1,38 @@ +/* eslint-disable eslint-comments/disable-enable-pair, no-console */ + +/** + * External dependencies + */ +const execa = require( 'execa' ); +const glob = require( 'fast-glob' ); +const path = require( 'path' ); + +const tscPath = path.resolve( + __dirname, + '..', + '..', + 'node_modules', + '.bin', + 'tsc' +); + +async function main() { + const packagesWithTs = await glob( 'packages/*/tsconfig.json', { + cwd: path.resolve( __dirname, '..', '..' ), + } ); + const projectPaths = packagesWithTs.map( ( tsconfigPath ) => + path.resolve( path.dirname( tsconfigPath ) ) + ); + + const args = [ '-b', ...projectPaths, ...process.argv.slice( 2 ) ]; + + try { + await execa( tscPath, args, { stdio: 'inherit' } ); + } catch { + process.exitCode = 1; + } +} + +main().catch( ( err ) => { + throw err; +} ); diff --git a/package.json b/package.json index 59eb7a6020a7c..0cb3225bc91d4 100644 --- a/package.json +++ b/package.json @@ -180,7 +180,8 @@ "clean:packages": "rimraf ./packages/*/build ./packages/*/build-* ./.cache/*.tsbuildinfo ./packages/*/node_modules", "prebuild:packages": "npm run clean:packages && lerna run build", "build:packages": "node ./bin/packages/build.js", - "build": "npm run build:packages && wp-scripts build", + "build:package-types": "node ./bin/packages/build-types.js", + "build": "npm run build:packages && npm run build:package-types && wp-scripts build", "check-engines": "wp-scripts check-engines", "check-licenses": "concurrently \"wp-scripts check-licenses --prod --gpl2\" \"wp-scripts check-licenses --dev\"", "precheck-local-changes": "npm run docs:build", @@ -201,7 +202,6 @@ "lint-pkg-json": "wp-scripts lint-pkg-json . 'packages/*/package.json'", "lint-css": "wp-scripts lint-style '**/*.scss'", "lint-css:fix": "npm run lint-css -- --fix", - "lint-types": "tsc", "lint:md-js": "wp-scripts lint-md-js", "lint:md-docs": "wp-scripts lint-md-docs", "package-plugin": "./bin/build-plugin-zip.sh", From bee32b5c6a5bab03c3df2abe4721fe61932b172e Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 18:35:58 +0100 Subject: [PATCH 16/65] Disable token-list types --- packages/token-list/{tsconfig.json => _tsconfig.json} | 1 + packages/token-list/package.json | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) rename packages/token-list/{tsconfig.json => _tsconfig.json} (77%) diff --git a/packages/token-list/tsconfig.json b/packages/token-list/_tsconfig.json similarity index 77% rename from packages/token-list/tsconfig.json rename to packages/token-list/_tsconfig.json index a210dc6cd5989..1d396d0e9162c 100644 --- a/packages/token-list/tsconfig.json +++ b/packages/token-list/_tsconfig.json @@ -1,4 +1,5 @@ { + // Currently disabled, package does not typecheck "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", diff --git a/packages/token-list/package.json b/packages/token-list/package.json index 65aaa92b9a718..2e7947df9e8f5 100644 --- a/packages/token-list/package.json +++ b/packages/token-list/package.json @@ -19,7 +19,6 @@ "main": "build/index.js", "module": "build-module/index.js", "react-native": "src/index", - "types": "build-types", "dependencies": { "@babel/runtime": "^7.8.3", "lodash": "^4.17.15" From af14a3e4877c45718cb93f6239865d30da85e167 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 18:39:39 +0100 Subject: [PATCH 17/65] Remove ts cache from cleanup --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0cb3225bc91d4..6c187cc56f505 100644 --- a/package.json +++ b/package.json @@ -177,7 +177,7 @@ }, "scripts": { "prebuild": "npm run check-engines", - "clean:packages": "rimraf ./packages/*/build ./packages/*/build-* ./.cache/*.tsbuildinfo ./packages/*/node_modules", + "clean:packages": "rimraf ./packages/*/build ./packages/*/build-* ./packages/*/node_modules", "prebuild:packages": "npm run clean:packages && lerna run build", "build:packages": "node ./bin/packages/build.js", "build:package-types": "node ./bin/packages/build-types.js", From a10f1a5464b802a89d6c4927d011b740ce5fdf91 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 18:56:31 +0100 Subject: [PATCH 18/65] Include build-types in files --- packages/is-shallow-equal/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/is-shallow-equal/package.json b/packages/is-shallow-equal/package.json index dd36895545e34..8862ff55501a2 100644 --- a/packages/is-shallow-equal/package.json +++ b/packages/is-shallow-equal/package.json @@ -22,7 +22,8 @@ "files": [ "arrays.js", "index.js", - "objects.js" + "objects.js", + "build-types" ], "main": "index.js", "types": "build-types", From d9141ec59b0b8c976cb4eec0df635133e0e112a6 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 27 Feb 2020 18:57:52 +0100 Subject: [PATCH 19/65] Use "build" over "b" --- bin/packages/build-types.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/packages/build-types.js b/bin/packages/build-types.js index 7fcb153601cc1..67392268d1e00 100644 --- a/bin/packages/build-types.js +++ b/bin/packages/build-types.js @@ -24,7 +24,7 @@ async function main() { path.resolve( path.dirname( tsconfigPath ) ) ); - const args = [ '-b', ...projectPaths, ...process.argv.slice( 2 ) ]; + const args = [ '--build', ...projectPaths, ...process.argv.slice( 2 ) ]; try { await execa( tscPath, args, { stdio: 'inherit' } ); From 975461274fc90bfd8a12436ceefb3dfa2052864f Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 28 Feb 2020 11:27:43 +0100 Subject: [PATCH 20/65] Remove lint-types from lint This is now handled as part of build:package-types --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6c187cc56f505..7e3cb79816118 100644 --- a/package.json +++ b/package.json @@ -195,7 +195,7 @@ "fixtures:generate": "npm run fixtures:server-registered && cross-env GENERATE_MISSING_FIXTURES=y npm run test-unit", "fixtures:regenerate": "npm run fixtures:clean && npm run fixtures:generate", "format-js": "wp-scripts format-js", - "lint": "concurrently \"npm run lint-js\" \"npm run lint-pkg-json\" \"npm run lint-css\" \"npm run lint-types\"", + "lint": "concurrently \"npm run lint-js\" \"npm run lint-pkg-json\" \"npm run lint-css\"", "lint-js": "wp-scripts lint-js", "lint-js:fix": "npm run lint-js -- --fix", "lint-php": "npm run wp-env run composer run-script lint", From d6a20ea9c2ce86b69fe2457f0a86bdc0e2f4c4bd Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Tue, 3 Mar 2020 14:08:34 +0100 Subject: [PATCH 21/65] Clean caches, some config cleanup --- package.json | 2 +- packages/a11y/tsconfig.json | 5 +++-- packages/blob/tsconfig.json | 5 +++-- packages/dom-ready/tsconfig.json | 5 +++-- packages/i18n/tsconfig.json | 4 ++-- packages/is-shallow-equal/tsconfig.json | 2 +- packages/priority-queue/tsconfig.json | 5 +++-- packages/token-list/_tsconfig.json | 3 ++- packages/url/tsconfig.json | 5 +++-- packages/warning/tsconfig.json | 4 ++-- 10 files changed, 23 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 7e3cb79816118..194c2e7896781 100644 --- a/package.json +++ b/package.json @@ -177,7 +177,7 @@ }, "scripts": { "prebuild": "npm run check-engines", - "clean:packages": "rimraf ./packages/*/build ./packages/*/build-* ./packages/*/node_modules", + "clean:packages": "rimraf ./packages/*/build ./packages/*/build-* ./packages/*/node_modules .cache/*.tsbuildinfo", "prebuild:packages": "npm run clean:packages && lerna run build", "build:packages": "node ./bin/packages/build.js", "build:package-types": "node ./bin/packages/build-types.js", diff --git a/packages/a11y/tsconfig.json b/packages/a11y/tsconfig.json index 3f90daf8d02e2..888936b5cc33b 100644 --- a/packages/a11y/tsconfig.json +++ b/packages/a11y/tsconfig.json @@ -2,8 +2,9 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types", + "declarationDir": "build-types", "tsBuildInfoFile": "../../.cache/a11y.tsbuildinfo" }, - "references": [ { "path": "../dom-ready" } ] + "references": [ { "path": "../dom-ready" } ], + "include": [ "src/**/*" ] } diff --git a/packages/blob/tsconfig.json b/packages/blob/tsconfig.json index ee67cda5160dc..d10c7b2684a92 100644 --- a/packages/blob/tsconfig.json +++ b/packages/blob/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types", + "declarationDir": "build-types", "tsBuildInfoFile": "../../.cache/blob.tsbuildinfo" - } + }, + "include": [ "src/**/*" ] } diff --git a/packages/dom-ready/tsconfig.json b/packages/dom-ready/tsconfig.json index 8832a734adb53..0c22ff658840f 100644 --- a/packages/dom-ready/tsconfig.json +++ b/packages/dom-ready/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types", + "declarationDir": "build-types", "tsBuildInfoFile": "../../.cache/dom-ready.tsbuildinfo" - } + }, + "include": [ "src/**/*" ] } diff --git a/packages/i18n/tsconfig.json b/packages/i18n/tsconfig.json index d732484ff9d86..55c62b8db8243 100644 --- a/packages/i18n/tsconfig.json +++ b/packages/i18n/tsconfig.json @@ -3,8 +3,8 @@ "compilerOptions": { "noImplicitAny": false, "rootDir": "src", - "outDir": "build-types", + "declarationDir": "build-types", "tsBuildInfoFile": "../../.cache/i18n.tsbuildinfo" }, - "include": [ "src/**/*.js" ] + "include": [ "src/**/*" ] } diff --git a/packages/is-shallow-equal/tsconfig.json b/packages/is-shallow-equal/tsconfig.json index cd65275ffa019..d0fcde67ab652 100644 --- a/packages/is-shallow-equal/tsconfig.json +++ b/packages/is-shallow-equal/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": ".", - "outDir": "build-types", + "declarationDir": "build-types", "tsBuildInfoFile": "../../.cache/is-shallow-equal.tsbuildinfo" }, "files": [ "arrays.js", "index.js", "objects.js" ] diff --git a/packages/priority-queue/tsconfig.json b/packages/priority-queue/tsconfig.json index 8387bbe84cecc..61fd34c5a440b 100644 --- a/packages/priority-queue/tsconfig.json +++ b/packages/priority-queue/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types", + "declarationDir": "build-types", "tsBuildInfoFile": "../../.cache/priority-queue.tsbuildinfo" - } + }, + "include": [ "src/**/*" ] } diff --git a/packages/token-list/_tsconfig.json b/packages/token-list/_tsconfig.json index 1d396d0e9162c..44b71f0525a8d 100644 --- a/packages/token-list/_tsconfig.json +++ b/packages/token-list/_tsconfig.json @@ -5,5 +5,6 @@ "rootDir": "src", "outDir": "build-types", "tsBuildInfoFile": "../../.cache/token-list.tsbuildinfo" - } + }, + "include": [ "src/**/*" ] } diff --git a/packages/url/tsconfig.json b/packages/url/tsconfig.json index f71a7c9817166..8aa2a06dc8ab5 100644 --- a/packages/url/tsconfig.json +++ b/packages/url/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types", + "declarationDir": "build-types", "tsBuildInfoFile": "../../.cache/url.tsbuildinfo" - } + }, + "include": [ "src/**/*" ] } diff --git a/packages/warning/tsconfig.json b/packages/warning/tsconfig.json index ab43cdf9bdb9a..439ef25c3cf64 100644 --- a/packages/warning/tsconfig.json +++ b/packages/warning/tsconfig.json @@ -2,8 +2,8 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types", + "declarationDir": "build-types", "tsBuildInfoFile": "../../.cache/warning.tsbuildinfo" }, - "include": [ "src/**/*.js" ] + "include": [ "src/**/*" ] } From 4cfe893561cfe4d3f289906c9ecccc3da0ae3463 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Tue, 3 Mar 2020 14:12:34 +0100 Subject: [PATCH 22/65] Remove redundant resolve --- bin/packages/build-types.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/packages/build-types.js b/bin/packages/build-types.js index 67392268d1e00..0301212807fd1 100644 --- a/bin/packages/build-types.js +++ b/bin/packages/build-types.js @@ -21,7 +21,7 @@ async function main() { cwd: path.resolve( __dirname, '..', '..' ), } ); const projectPaths = packagesWithTs.map( ( tsconfigPath ) => - path.resolve( path.dirname( tsconfigPath ) ) + path.dirname( tsconfigPath ) ); const args = [ '--build', ...projectPaths, ...process.argv.slice( 2 ) ]; From ba8e7c5940ecbe0b09d862791474e40871a6fee4 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 5 Mar 2020 19:50:52 +0100 Subject: [PATCH 23/65] No async, no catch --- bin/packages/build-types.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/bin/packages/build-types.js b/bin/packages/build-types.js index 0301212807fd1..b61ad759a1a0a 100644 --- a/bin/packages/build-types.js +++ b/bin/packages/build-types.js @@ -16,8 +16,8 @@ const tscPath = path.resolve( 'tsc' ); -async function main() { - const packagesWithTs = await glob( 'packages/*/tsconfig.json', { +function main() { + const packagesWithTs = glob.sync( 'packages/*/tsconfig.json', { cwd: path.resolve( __dirname, '..', '..' ), } ); const projectPaths = packagesWithTs.map( ( tsconfigPath ) => @@ -26,13 +26,7 @@ async function main() { const args = [ '--build', ...projectPaths, ...process.argv.slice( 2 ) ]; - try { - await execa( tscPath, args, { stdio: 'inherit' } ); - } catch { - process.exitCode = 1; - } + execa.sync( tscPath, args, { stdio: 'inherit' } ); } -main().catch( ( err ) => { - throw err; -} ); +main(); From 214e1ff926dd4629c37bae50709e217a11f0fd26 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 5 Mar 2020 19:53:35 +0100 Subject: [PATCH 24/65] Use default .tsbuildinfo location --- .gitignore | 1 + package.json | 2 +- packages/a11y/tsconfig.json | 3 +-- packages/blob/tsconfig.json | 3 +-- packages/dom-ready/tsconfig.json | 3 +-- packages/i18n/tsconfig.json | 3 +-- packages/is-shallow-equal/tsconfig.json | 3 +-- packages/priority-queue/tsconfig.json | 3 +-- packages/token-list/_tsconfig.json | 3 +-- packages/url/tsconfig.json | 3 +-- packages/warning/tsconfig.json | 3 +-- 11 files changed, 11 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 9520a90404511..a3ebac937fc66 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ yarn.lock playground/dist .cache +*.tsbuildinfo # Report generated from jest-junit test/native/junit.xml diff --git a/package.json b/package.json index 194c2e7896781..34bfc336c2010 100644 --- a/package.json +++ b/package.json @@ -177,7 +177,7 @@ }, "scripts": { "prebuild": "npm run check-engines", - "clean:packages": "rimraf ./packages/*/build ./packages/*/build-* ./packages/*/node_modules .cache/*.tsbuildinfo", + "clean:packages": "rimraf ./packages/*/build ./packages/*/build-* ./packages/*/node_modules ./packages/*/tsconfig.tsbuildinfo", "prebuild:packages": "npm run clean:packages && lerna run build", "build:packages": "node ./bin/packages/build.js", "build:package-types": "node ./bin/packages/build-types.js", diff --git a/packages/a11y/tsconfig.json b/packages/a11y/tsconfig.json index 888936b5cc33b..1a0a90bc8cb58 100644 --- a/packages/a11y/tsconfig.json +++ b/packages/a11y/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "declarationDir": "build-types", - "tsBuildInfoFile": "../../.cache/a11y.tsbuildinfo" + "declarationDir": "build-types" }, "references": [ { "path": "../dom-ready" } ], "include": [ "src/**/*" ] diff --git a/packages/blob/tsconfig.json b/packages/blob/tsconfig.json index d10c7b2684a92..3c2c31f506f13 100644 --- a/packages/blob/tsconfig.json +++ b/packages/blob/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "declarationDir": "build-types", - "tsBuildInfoFile": "../../.cache/blob.tsbuildinfo" + "declarationDir": "build-types" }, "include": [ "src/**/*" ] } diff --git a/packages/dom-ready/tsconfig.json b/packages/dom-ready/tsconfig.json index 0c22ff658840f..3c2c31f506f13 100644 --- a/packages/dom-ready/tsconfig.json +++ b/packages/dom-ready/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "declarationDir": "build-types", - "tsBuildInfoFile": "../../.cache/dom-ready.tsbuildinfo" + "declarationDir": "build-types" }, "include": [ "src/**/*" ] } diff --git a/packages/i18n/tsconfig.json b/packages/i18n/tsconfig.json index 55c62b8db8243..cccd60dd6447e 100644 --- a/packages/i18n/tsconfig.json +++ b/packages/i18n/tsconfig.json @@ -3,8 +3,7 @@ "compilerOptions": { "noImplicitAny": false, "rootDir": "src", - "declarationDir": "build-types", - "tsBuildInfoFile": "../../.cache/i18n.tsbuildinfo" + "declarationDir": "build-types" }, "include": [ "src/**/*" ] } diff --git a/packages/is-shallow-equal/tsconfig.json b/packages/is-shallow-equal/tsconfig.json index d0fcde67ab652..00ca88da64d40 100644 --- a/packages/is-shallow-equal/tsconfig.json +++ b/packages/is-shallow-equal/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": ".", - "declarationDir": "build-types", - "tsBuildInfoFile": "../../.cache/is-shallow-equal.tsbuildinfo" + "declarationDir": "build-types" }, "files": [ "arrays.js", "index.js", "objects.js" ] } diff --git a/packages/priority-queue/tsconfig.json b/packages/priority-queue/tsconfig.json index 61fd34c5a440b..3c2c31f506f13 100644 --- a/packages/priority-queue/tsconfig.json +++ b/packages/priority-queue/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "declarationDir": "build-types", - "tsBuildInfoFile": "../../.cache/priority-queue.tsbuildinfo" + "declarationDir": "build-types" }, "include": [ "src/**/*" ] } diff --git a/packages/token-list/_tsconfig.json b/packages/token-list/_tsconfig.json index 44b71f0525a8d..346d1613286c5 100644 --- a/packages/token-list/_tsconfig.json +++ b/packages/token-list/_tsconfig.json @@ -3,8 +3,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types", - "tsBuildInfoFile": "../../.cache/token-list.tsbuildinfo" + "outDir": "build-types" }, "include": [ "src/**/*" ] } diff --git a/packages/url/tsconfig.json b/packages/url/tsconfig.json index 8aa2a06dc8ab5..3c2c31f506f13 100644 --- a/packages/url/tsconfig.json +++ b/packages/url/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "declarationDir": "build-types", - "tsBuildInfoFile": "../../.cache/url.tsbuildinfo" + "declarationDir": "build-types" }, "include": [ "src/**/*" ] } diff --git a/packages/warning/tsconfig.json b/packages/warning/tsconfig.json index 439ef25c3cf64..3c2c31f506f13 100644 --- a/packages/warning/tsconfig.json +++ b/packages/warning/tsconfig.json @@ -2,8 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "declarationDir": "build-types", - "tsBuildInfoFile": "../../.cache/warning.tsbuildinfo" + "declarationDir": "build-types" }, "include": [ "src/**/*" ] } From 1042f717ec2531b0f5c923698145106a2834f0ae Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 5 Mar 2020 21:10:06 +0100 Subject: [PATCH 25/65] Clean up tsconfig --- tsconfig.base.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tsconfig.base.json b/tsconfig.base.json index 1c0f4716921b4..4d9920e600802 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -11,12 +11,12 @@ "declarationMap": true, "composite": true, "emitDeclarationOnly": true, - // "isolatedModules": true, + "isolatedModules": true, /* Strict Type-Checking Options */ - "strict": true /* Enable all strict type-checking options. */, + "strict": true, "strictNullChecks": true, - "noImplicitAny": true /* Raise error on expressions and declarations with an implied 'any' type. */, + "noImplicitAny": true, /* Additional Checks */ "noUnusedLocals": true, From 0cca9870b5f7b17d1c175357add8d244a7d8c637 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 5 Mar 2020 21:29:25 +0100 Subject: [PATCH 26/65] "Fix" token-list relax strictness --- packages/token-list/package.json | 1 + packages/token-list/{_tsconfig.json => tsconfig.json} | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) rename packages/token-list/{_tsconfig.json => tsconfig.json} (59%) diff --git a/packages/token-list/package.json b/packages/token-list/package.json index 2e7947df9e8f5..65aaa92b9a718 100644 --- a/packages/token-list/package.json +++ b/packages/token-list/package.json @@ -19,6 +19,7 @@ "main": "build/index.js", "module": "build-module/index.js", "react-native": "src/index", + "types": "build-types", "dependencies": { "@babel/runtime": "^7.8.3", "lodash": "^4.17.15" diff --git a/packages/token-list/_tsconfig.json b/packages/token-list/tsconfig.json similarity index 59% rename from packages/token-list/_tsconfig.json rename to packages/token-list/tsconfig.json index 346d1613286c5..b97f385f9f91d 100644 --- a/packages/token-list/_tsconfig.json +++ b/packages/token-list/tsconfig.json @@ -1,9 +1,10 @@ { - // Currently disabled, package does not typecheck "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types" + "outDir": "build-types", + "strictNullChecks": false, + "noImplicitAny": false }, "include": [ "src/**/*" ] } From 71b0dd86381ec35db0331eebdc784f3db1611073 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 5 Mar 2020 21:31:55 +0100 Subject: [PATCH 27/65] Use eslint dis/enable no-console pair --- bin/packages/build-types.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/packages/build-types.js b/bin/packages/build-types.js index b61ad759a1a0a..b2b96aa5aeea7 100644 --- a/bin/packages/build-types.js +++ b/bin/packages/build-types.js @@ -1,5 +1,3 @@ -/* eslint-disable eslint-comments/disable-enable-pair, no-console */ - /** * External dependencies */ @@ -7,6 +5,8 @@ const execa = require( 'execa' ); const glob = require( 'fast-glob' ); const path = require( 'path' ); +/* eslint-disable no-console */ + const tscPath = path.resolve( __dirname, '..', @@ -30,3 +30,5 @@ function main() { } main(); + +/* eslint-enable no-console */ From 1268c2f9d03bcecb00dd8f120681d8fa27eaeb8f Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 5 Mar 2020 21:35:32 +0100 Subject: [PATCH 28/65] Move types built to build:packages --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 34bfc336c2010..f63452d4de417 100644 --- a/package.json +++ b/package.json @@ -179,9 +179,9 @@ "prebuild": "npm run check-engines", "clean:packages": "rimraf ./packages/*/build ./packages/*/build-* ./packages/*/node_modules ./packages/*/tsconfig.tsbuildinfo", "prebuild:packages": "npm run clean:packages && lerna run build", - "build:packages": "node ./bin/packages/build.js", + "build:packages": "npm run build:package-types && node ./bin/packages/build.js", "build:package-types": "node ./bin/packages/build-types.js", - "build": "npm run build:packages && npm run build:package-types && wp-scripts build", + "build": "npm run build:packages && wp-scripts build", "check-engines": "wp-scripts check-engines", "check-licenses": "concurrently \"wp-scripts check-licenses --prod --gpl2\" \"wp-scripts check-licenses --dev\"", "precheck-local-changes": "npm run docs:build", From 80c0a025eac9ce0c088f4f73ddc81fa46056338d Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 6 Mar 2020 18:44:31 +0100 Subject: [PATCH 29/65] Add TypeScript to packages/README --- packages/README.md | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/packages/README.md b/packages/README.md index 30cccbed973c4..05a8fe9e9a12d 100644 --- a/packages/README.md +++ b/packages/README.md @@ -190,5 +190,61 @@ npm run publish:legacy This is usually necessary when adding bug fixes or security patches to the earlier versions of WordPress. +## TypeScript + +The [TypeScript](http://www.typescriptlang.org/) language is a typed superset of JavaScript that compiles to plain JavaScript. +Gutenberg does not use the TypeScript language, however TypeScript has powerful tooling that can be applied to JavaScript projects. + +Gutenberg uses TypeScript for several reasons, including: + +- Powerful editor integrations improve developer experience. +- Type system can detect some issues and lead to more robust software. +- Type declarations can be produced to allow other projects to benefit from these advantages as well. + +### Using TypeScript + +Gutenberg uses TypeScript by running the TypeScript compiler (`tsc`) on select packages. +These packages benefit from type checking and produced type declarations in the published packages. + +To opt-in to TypeScript tooling, packages should include a `tsconfig.json` file in the package root. +The presence of the `tsconfig.json` file indicates to our build system that the package has opted-in and will be included in the TypeScript build process. + +A `tsconfig.json` file should look like the following (comments are not necessary): + +```jsonc +{ + // Extends a base configuration common to most packages + "extends": "../../tsconfig.base.json", + + // Options for the TypeScript compiler + // We'll usually set our `rootDir` and `declarationDir` as follows, which is specific + // to each project. + "compilerOptions": { + "rootDir": "src", + "declarationDir": "build-types" + }, + + // Which source files should be included + "include": [ "src/**/*" ], + + // Other WordPress package dependencies that have opted-in to TypeScript should be listed + // here. In this case, our package depends on `@wordpress/dom-ready`. + "references": [ { "path": "../dom-ready" } ] +} +``` + +Type declarations will be produced in the `build-types` which should be included in the published package. +For consumers to use the published type declarations, we'll set the `types` field in `package.json`: + +```json +{ + "main": "build/index.js", + "main-module": "build-module/index.js", + "types": "build-types" +} +``` + +Ensure that the `build-types` directory will be included in the published package, for example if a `files` field is declared. + [lerna]: https://lerna.js.org/ [npm]: https://www.npmjs.com/ From adbb0dd1a9517cebed75f1f099d06f5246e1e9e6 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 6 Mar 2020 19:10:53 +0100 Subject: [PATCH 30/65] Ignore cli input --- bin/packages/build-types.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/packages/build-types.js b/bin/packages/build-types.js index b2b96aa5aeea7..400b5d794720b 100644 --- a/bin/packages/build-types.js +++ b/bin/packages/build-types.js @@ -24,7 +24,7 @@ function main() { path.dirname( tsconfigPath ) ); - const args = [ '--build', ...projectPaths, ...process.argv.slice( 2 ) ]; + const args = [ '--build', ...projectPaths ]; execa.sync( tscPath, args, { stdio: 'inherit' } ); } From 973f5fbf6da7115af2e561760a2f2dafe7be7d41 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 6 Mar 2020 19:37:14 +0100 Subject: [PATCH 31/65] Add build:package-types to lint-staged --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f63452d4de417..f5206742b966a 100644 --- a/package.json +++ b/package.json @@ -248,7 +248,8 @@ ], "*.js": [ "wp-scripts format-js", - "wp-scripts lint-js" + "wp-scripts lint-js", + "npm run build:package-types" ], "{docs/{toc.json,tool/*.js},packages/{*/README.md,components/src/*/**/README.md}}": [ "node ./docs/tool/index.js" From 09c99550cd2b44b7519fcac5d598248f2cd113aa Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 6 Mar 2020 19:52:17 +0100 Subject: [PATCH 32/65] Add travis job --- .travis.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.travis.yml b/.travis.yml index 8a430251588a0..baf9a3bb3d431 100644 --- a/.travis.yml +++ b/.travis.yml @@ -114,6 +114,13 @@ jobs: script: - npx eslint --parser-options=ecmaVersion:5 --no-eslintrc --no-ignore ./build/**/*.js + - name: Typecheck + install: + - npm ci + script: + - npm run build:package-types + + - name: Build artifacts install: # A "full" install is executed, since `npm ci` does not always exit From 2e3bdce1b80c169ba2b138f89ad81885fa68a9fd Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Sat, 7 Mar 2020 00:24:23 +0100 Subject: [PATCH 33/65] Add and use lint-staged-typecheck bin --- bin/packages/lint-staged-typecheck.js | 35 +++++++++++++++++++++++++++ package.json | 6 ++--- 2 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 bin/packages/lint-staged-typecheck.js diff --git a/bin/packages/lint-staged-typecheck.js b/bin/packages/lint-staged-typecheck.js new file mode 100644 index 0000000000000..4247ca821017f --- /dev/null +++ b/bin/packages/lint-staged-typecheck.js @@ -0,0 +1,35 @@ +/** + * External dependencies + */ +const _ = require( 'lodash' ); +const path = require( 'path' ); +const fs = require( 'fs' ); +const execa = require( 'execa' ); + +/* eslint-disable no-console */ + +const repoRoot = path.join( __dirname, '..', '..' ); +const tscPath = path.join( repoRoot, 'node_modules', '.bin', 'tsc' ); + +// lint-staged passes full paths to staged changes +/** @type {string[]} */ +const changedFiles = process.argv.slice( 2 ); + +// Transform changed files to package directories containing tsconfig.json +const changedPackages = _.uniq( + changedFiles.map( ( fullPath ) => { + const relativePath = path.relative( repoRoot, fullPath ); + return path.join( ...relativePath.split( path.sep ).slice( 0, 2 ) ); + } ) +).filter( ( packageRoot ) => + fs.existsSync( path.join( packageRoot, 'tsconfig.json' ) ) +); + +try { + execa.sync( tscPath, [ '--build', ...changedPackages ] ); +} catch ( err ) { + console.error( err.message ); + process.exitCode = 1; +} + +/* eslint-enable no-console */ diff --git a/package.json b/package.json index f5206742b966a..a1cc1ae3373e8 100644 --- a/package.json +++ b/package.json @@ -248,15 +248,15 @@ ], "*.js": [ "wp-scripts format-js", - "wp-scripts lint-js", - "npm run build:package-types" + "wp-scripts lint-js" ], "{docs/{toc.json,tool/*.js},packages/{*/README.md,components/src/*/**/README.md}}": [ "node ./docs/tool/index.js" ], "packages/**/*.js": [ "node ./bin/api-docs/update-api-docs.js", - "node ./bin/api-docs/are-api-docs-unstaged.js" + "node ./bin/api-docs/are-api-docs-unstaged.js", + "node ./bin/packages/lint-staged-typecheck.js" ] }, "wp-env": { From 7c277f4c04c491819fca403931f9b89b27dc1bf9 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Sat, 7 Mar 2020 00:34:34 +0100 Subject: [PATCH 34/65] Update bin/packages/lint-staged-typecheck.js --- bin/packages/lint-staged-typecheck.js | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/packages/lint-staged-typecheck.js b/bin/packages/lint-staged-typecheck.js index 4247ca821017f..a3d8577ad4c45 100644 --- a/bin/packages/lint-staged-typecheck.js +++ b/bin/packages/lint-staged-typecheck.js @@ -12,7 +12,6 @@ const repoRoot = path.join( __dirname, '..', '..' ); const tscPath = path.join( repoRoot, 'node_modules', '.bin', 'tsc' ); // lint-staged passes full paths to staged changes -/** @type {string[]} */ const changedFiles = process.argv.slice( 2 ); // Transform changed files to package directories containing tsconfig.json From d11fe6a28b023997d6521308451360f801a7fdd3 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Sat, 7 Mar 2020 12:04:14 +0100 Subject: [PATCH 35/65] Restructure is-shallow-equal --- .npmpackagejsonlintignore | 1 + packages/is-shallow-equal/.npmignore | 2 ++ packages/is-shallow-equal/arrays/package.json | 3 +++ packages/is-shallow-equal/objects/package.json | 3 +++ packages/is-shallow-equal/package.json | 8 +------- packages/is-shallow-equal/{ => src}/arrays.js | 0 packages/is-shallow-equal/{ => src}/index.js | 0 packages/is-shallow-equal/{ => src}/objects.js | 0 packages/is-shallow-equal/tsconfig.json | 4 ++-- 9 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 .npmpackagejsonlintignore create mode 100644 packages/is-shallow-equal/.npmignore create mode 100644 packages/is-shallow-equal/arrays/package.json create mode 100644 packages/is-shallow-equal/objects/package.json rename packages/is-shallow-equal/{ => src}/arrays.js (100%) rename packages/is-shallow-equal/{ => src}/index.js (100%) rename packages/is-shallow-equal/{ => src}/objects.js (100%) diff --git a/.npmpackagejsonlintignore b/.npmpackagejsonlintignore new file mode 100644 index 0000000000000..77b9740b6311b --- /dev/null +++ b/.npmpackagejsonlintignore @@ -0,0 +1 @@ +packages/is-shallow-equal/*/package.json diff --git a/packages/is-shallow-equal/.npmignore b/packages/is-shallow-equal/.npmignore new file mode 100644 index 0000000000000..848649efce958 --- /dev/null +++ b/packages/is-shallow-equal/.npmignore @@ -0,0 +1,2 @@ +benchmark +test diff --git a/packages/is-shallow-equal/arrays/package.json b/packages/is-shallow-equal/arrays/package.json new file mode 100644 index 0000000000000..d557aa9b3dc1f --- /dev/null +++ b/packages/is-shallow-equal/arrays/package.json @@ -0,0 +1,3 @@ +{ + "main": "../src/arrays.js" +} diff --git a/packages/is-shallow-equal/objects/package.json b/packages/is-shallow-equal/objects/package.json new file mode 100644 index 0000000000000..3da252ad57007 --- /dev/null +++ b/packages/is-shallow-equal/objects/package.json @@ -0,0 +1,3 @@ +{ + "main": "../src/objects.js" +} diff --git a/packages/is-shallow-equal/package.json b/packages/is-shallow-equal/package.json index 8862ff55501a2..8183d9eab3a26 100644 --- a/packages/is-shallow-equal/package.json +++ b/packages/is-shallow-equal/package.json @@ -19,13 +19,7 @@ "bugs": { "url": "https://github.com/WordPress/gutenberg/issues" }, - "files": [ - "arrays.js", - "index.js", - "objects.js", - "build-types" - ], - "main": "index.js", + "main": "src/index.js", "types": "build-types", "sideEffects": false, "dependencies": { diff --git a/packages/is-shallow-equal/arrays.js b/packages/is-shallow-equal/src/arrays.js similarity index 100% rename from packages/is-shallow-equal/arrays.js rename to packages/is-shallow-equal/src/arrays.js diff --git a/packages/is-shallow-equal/index.js b/packages/is-shallow-equal/src/index.js similarity index 100% rename from packages/is-shallow-equal/index.js rename to packages/is-shallow-equal/src/index.js diff --git a/packages/is-shallow-equal/objects.js b/packages/is-shallow-equal/src/objects.js similarity index 100% rename from packages/is-shallow-equal/objects.js rename to packages/is-shallow-equal/src/objects.js diff --git a/packages/is-shallow-equal/tsconfig.json b/packages/is-shallow-equal/tsconfig.json index 00ca88da64d40..3c2c31f506f13 100644 --- a/packages/is-shallow-equal/tsconfig.json +++ b/packages/is-shallow-equal/tsconfig.json @@ -1,8 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "rootDir": ".", + "rootDir": "src", "declarationDir": "build-types" }, - "files": [ "arrays.js", "index.js", "objects.js" ] + "include": [ "src/**/*" ] } From 384c78e4741734fba73b0672cb88a6948671ff6e Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 11 Mar 2020 18:59:08 +0100 Subject: [PATCH 36/65] Bump to TS 3.8.3 --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index cbe6b43848eaa..842c0fa0e00a5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39856,9 +39856,9 @@ "dev": true }, "typescript": { - "version": "3.8.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.2.tgz", - "integrity": "sha512-EgOVgL/4xfVrCMbhYKUQTdF37SQn4Iw73H5BgCrF1Abdun7Kwy/QZsE/ssAy0y4LxBbvua3PIbFsbRczWWnDdQ==", + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", + "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==", "dev": true }, "ua-parser-js": { diff --git a/package.json b/package.json index a1cc1ae3373e8..6cbd887da08f5 100644 --- a/package.json +++ b/package.json @@ -170,7 +170,7 @@ "sprintf-js": "1.1.1", "style-loader": "1.0.0", "stylelint-config-wordpress": "13.1.0", - "typescript": "3.8.2", + "typescript": "3.8.3", "uuid": "3.3.2", "webpack": "4.42.0", "worker-farm": "1.7.0" From 36d4649214bfb80b508fbda1f776ca320f1f098e Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 11 Mar 2020 19:09:09 +0100 Subject: [PATCH 37/65] Type TokenList --- packages/token-list/src/index.js | 39 ++++++++++++++++++++++++++++--- packages/token-list/tsconfig.json | 4 +--- 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/packages/token-list/src/index.js b/packages/token-list/src/index.js index 08f63abfa2612..eaa5e892ddf1c 100644 --- a/packages/token-list/src/index.js +++ b/packages/token-list/src/index.js @@ -17,9 +17,42 @@ export default class TokenList { constructor( initialValue = '' ) { this.value = initialValue; - [ 'entries', 'forEach', 'keys', 'values' ].forEach( ( fn ) => { - this[ fn ] = ( ...args ) => this._valueAsArray[ fn ]( ...args ); - } ); + // Disable reason: These are type hints on the class. + /* eslint-disable no-unused-expressions */ + /** @type string */ + this._currentValue; + + /** @type string[] */ + this._valueAsArray; + /* eslint-enable no-unused-expressions */ + } + + /** + * @param {Parameters['entries']>} args + */ + entries( ...args ) { + return this._valueAsArray.entries( ...args ); + } + + /** + * @param {Parameters['forEach']>} args + */ + forEach( ...args ) { + return this._valueAsArray.forEach( ...args ); + } + + /** + * @param {Parameters['keys']>} args + */ + keys( ...args ) { + return this._valueAsArray.keys( ...args ); + } + + /** + * @param {Parameters['values']>} args + */ + values( ...args ) { + return this._valueAsArray.values( ...args ); } /** diff --git a/packages/token-list/tsconfig.json b/packages/token-list/tsconfig.json index b97f385f9f91d..e22ff86abb6f2 100644 --- a/packages/token-list/tsconfig.json +++ b/packages/token-list/tsconfig.json @@ -2,9 +2,7 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "outDir": "build-types", - "strictNullChecks": false, - "noImplicitAny": false + "outDir": "build-types" }, "include": [ "src/**/*" ] } From 7e71ee667802a68d55a8399c0ed704734cce4c3f Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 20 Mar 2020 17:19:29 +0100 Subject: [PATCH 38/65] Add project-management-automation to typed packages --- packages/project-management-automation/package.json | 1 + packages/project-management-automation/tsconfig.json | 8 ++++++++ 2 files changed, 9 insertions(+) create mode 100644 packages/project-management-automation/tsconfig.json diff --git a/packages/project-management-automation/package.json b/packages/project-management-automation/package.json index 3e41185ada8c0..4e1d7bcf3e368 100644 --- a/packages/project-management-automation/package.json +++ b/packages/project-management-automation/package.json @@ -17,6 +17,7 @@ "url": "https://github.com/WordPress/gutenberg/issues" }, "main": "lib/index.js", + "types": "build-types", "dependencies": { "@actions/core": "^1.0.0", "@actions/github": "^1.0.0", diff --git a/packages/project-management-automation/tsconfig.json b/packages/project-management-automation/tsconfig.json new file mode 100644 index 0000000000000..426ab13d0aa8f --- /dev/null +++ b/packages/project-management-automation/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": "lib", + "declarationDir": "build-types" + }, + "include": [ "lib/**/*" ] +} From 5ab371b32b55217ee98be87815bb785f93649f59 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 20 Mar 2020 17:21:52 +0100 Subject: [PATCH 39/65] Use lib for uncompiled published code --- packages/is-shallow-equal/arrays/package.json | 2 +- packages/is-shallow-equal/{src => lib}/arrays.js | 0 packages/is-shallow-equal/{src => lib}/index.js | 0 packages/is-shallow-equal/{src => lib}/objects.js | 0 packages/is-shallow-equal/objects/package.json | 2 +- packages/is-shallow-equal/package.json | 2 +- packages/is-shallow-equal/tsconfig.json | 4 ++-- 7 files changed, 5 insertions(+), 5 deletions(-) rename packages/is-shallow-equal/{src => lib}/arrays.js (100%) rename packages/is-shallow-equal/{src => lib}/index.js (100%) rename packages/is-shallow-equal/{src => lib}/objects.js (100%) diff --git a/packages/is-shallow-equal/arrays/package.json b/packages/is-shallow-equal/arrays/package.json index d557aa9b3dc1f..f9f6b27edb413 100644 --- a/packages/is-shallow-equal/arrays/package.json +++ b/packages/is-shallow-equal/arrays/package.json @@ -1,3 +1,3 @@ { - "main": "../src/arrays.js" + "main": "../lib/arrays.js" } diff --git a/packages/is-shallow-equal/src/arrays.js b/packages/is-shallow-equal/lib/arrays.js similarity index 100% rename from packages/is-shallow-equal/src/arrays.js rename to packages/is-shallow-equal/lib/arrays.js diff --git a/packages/is-shallow-equal/src/index.js b/packages/is-shallow-equal/lib/index.js similarity index 100% rename from packages/is-shallow-equal/src/index.js rename to packages/is-shallow-equal/lib/index.js diff --git a/packages/is-shallow-equal/src/objects.js b/packages/is-shallow-equal/lib/objects.js similarity index 100% rename from packages/is-shallow-equal/src/objects.js rename to packages/is-shallow-equal/lib/objects.js diff --git a/packages/is-shallow-equal/objects/package.json b/packages/is-shallow-equal/objects/package.json index 3da252ad57007..87c2d045cbc3c 100644 --- a/packages/is-shallow-equal/objects/package.json +++ b/packages/is-shallow-equal/objects/package.json @@ -1,3 +1,3 @@ { - "main": "../src/objects.js" + "main": "../lib/objects.js" } diff --git a/packages/is-shallow-equal/package.json b/packages/is-shallow-equal/package.json index 8183d9eab3a26..a4b3883e3330c 100644 --- a/packages/is-shallow-equal/package.json +++ b/packages/is-shallow-equal/package.json @@ -19,7 +19,7 @@ "bugs": { "url": "https://github.com/WordPress/gutenberg/issues" }, - "main": "src/index.js", + "main": "lib/index.js", "types": "build-types", "sideEffects": false, "dependencies": { diff --git a/packages/is-shallow-equal/tsconfig.json b/packages/is-shallow-equal/tsconfig.json index 3c2c31f506f13..426ab13d0aa8f 100644 --- a/packages/is-shallow-equal/tsconfig.json +++ b/packages/is-shallow-equal/tsconfig.json @@ -1,8 +1,8 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "rootDir": "src", + "rootDir": "lib", "declarationDir": "build-types" }, - "include": [ "src/**/*" ] + "include": [ "lib/**/*" ] } From 8fc3c0e70ca95578bfe11c2897d9e0ec0a390e89 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 20 Mar 2020 17:26:11 +0100 Subject: [PATCH 40/65] Fix implicit any type --- packages/project-management-automation/lib/if-not-fork.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/project-management-automation/lib/if-not-fork.js b/packages/project-management-automation/lib/if-not-fork.js index 5c8e65adb4d9d..7ab214026cf8b 100644 --- a/packages/project-management-automation/lib/if-not-fork.js +++ b/packages/project-management-automation/lib/if-not-fork.js @@ -15,6 +15,7 @@ const debug = require( './debug' ); * @return {WPAutomationTask} Enhanced task. */ function ifNotFork( handler ) { + /** @type {WPAutomationTask} */ const newHandler = ( payload, octokit ) => { if ( payload.pull_request.head.repo.full_name === From 7dc9a43720ea6776c972eaaad4e7f435da97937b Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 20 Mar 2020 17:34:15 +0100 Subject: [PATCH 41/65] Disable noImplicitAny for pma --- packages/project-management-automation/tsconfig.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/project-management-automation/tsconfig.json b/packages/project-management-automation/tsconfig.json index 426ab13d0aa8f..395281ecb0e72 100644 --- a/packages/project-management-automation/tsconfig.json +++ b/packages/project-management-automation/tsconfig.json @@ -2,7 +2,10 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "lib", - "declarationDir": "build-types" + "declarationDir": "build-types", + + // This is required due to a type error coming from missing types in @actions/github + "noImplicitAny": false }, "include": [ "lib/**/*" ] } From 94b945116d8d88b18bcfb0c8c078a72b435771a1 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 20 Mar 2020 17:41:35 +0100 Subject: [PATCH 42/65] Exclude react-native --- tsconfig.base.json | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tsconfig.base.json b/tsconfig.base.json index 4d9920e600802..150fa39973dc6 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -30,5 +30,14 @@ "esModuleInterop": false, "resolveJsonModule": true }, - "exclude": [ "**/benchmark", "**/test/**", "**/build/**", "**/build-*/**" ] + "exclude": [ + // Don't compile react-native types. + // They create incompatibilities and require a separate build. + "**/*.native.js", + + "**/benchmark", + "**/test/**", + "**/build/**", + "**/build-*/**" + ] } From 3230e83d0da66968a24abacbb16f16e97438264e Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 20 Mar 2020 19:15:10 +0100 Subject: [PATCH 43/65] Restore native checking, relax implicit any --- packages/url/tsconfig.json | 5 ++++- tsconfig.base.json | 11 +---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/packages/url/tsconfig.json b/packages/url/tsconfig.json index 3c2c31f506f13..70efdfe49990d 100644 --- a/packages/url/tsconfig.json +++ b/packages/url/tsconfig.json @@ -2,7 +2,10 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "src", - "declarationDir": "build-types" + "declarationDir": "build-types", + + // This is required because the `react-native-url-polyfill` dependency lacks types + "noImplicitAny": false }, "include": [ "src/**/*" ] } diff --git a/tsconfig.base.json b/tsconfig.base.json index 150fa39973dc6..4d9920e600802 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -30,14 +30,5 @@ "esModuleInterop": false, "resolveJsonModule": true }, - "exclude": [ - // Don't compile react-native types. - // They create incompatibilities and require a separate build. - "**/*.native.js", - - "**/benchmark", - "**/test/**", - "**/build/**", - "**/build-*/**" - ] + "exclude": [ "**/benchmark", "**/test/**", "**/build/**", "**/build-*/**" ] } From 47b24c3aa1e8a450884d40c4bc0ffb758308a1b2 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Sat, 21 Mar 2020 11:18:12 +0100 Subject: [PATCH 44/65] Improve is-shallow-equal structure - No package.json hack - No package.json lint ignore - Publish via files field --- .npmpackagejsonlintignore | 1 - packages/is-shallow-equal/.npmignore | 2 -- packages/is-shallow-equal/arrays.js | 1 + packages/is-shallow-equal/arrays/package.json | 3 --- packages/is-shallow-equal/objects.js | 1 + packages/is-shallow-equal/objects/package.json | 3 --- packages/is-shallow-equal/package.json | 6 ++++++ 7 files changed, 8 insertions(+), 9 deletions(-) delete mode 100644 .npmpackagejsonlintignore delete mode 100644 packages/is-shallow-equal/.npmignore create mode 100644 packages/is-shallow-equal/arrays.js delete mode 100644 packages/is-shallow-equal/arrays/package.json create mode 100644 packages/is-shallow-equal/objects.js delete mode 100644 packages/is-shallow-equal/objects/package.json diff --git a/.npmpackagejsonlintignore b/.npmpackagejsonlintignore deleted file mode 100644 index 77b9740b6311b..0000000000000 --- a/.npmpackagejsonlintignore +++ /dev/null @@ -1 +0,0 @@ -packages/is-shallow-equal/*/package.json diff --git a/packages/is-shallow-equal/.npmignore b/packages/is-shallow-equal/.npmignore deleted file mode 100644 index 848649efce958..0000000000000 --- a/packages/is-shallow-equal/.npmignore +++ /dev/null @@ -1,2 +0,0 @@ -benchmark -test diff --git a/packages/is-shallow-equal/arrays.js b/packages/is-shallow-equal/arrays.js new file mode 100644 index 0000000000000..e6fc3dc754c5e --- /dev/null +++ b/packages/is-shallow-equal/arrays.js @@ -0,0 +1 @@ +module.exports = require( './lib/arrays.js' ); diff --git a/packages/is-shallow-equal/arrays/package.json b/packages/is-shallow-equal/arrays/package.json deleted file mode 100644 index f9f6b27edb413..0000000000000 --- a/packages/is-shallow-equal/arrays/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "../lib/arrays.js" -} diff --git a/packages/is-shallow-equal/objects.js b/packages/is-shallow-equal/objects.js new file mode 100644 index 0000000000000..dc5b2405779df --- /dev/null +++ b/packages/is-shallow-equal/objects.js @@ -0,0 +1 @@ +module.exports = require( './lib/objects.js' ); diff --git a/packages/is-shallow-equal/objects/package.json b/packages/is-shallow-equal/objects/package.json deleted file mode 100644 index 87c2d045cbc3c..0000000000000 --- a/packages/is-shallow-equal/objects/package.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "main": "../lib/objects.js" -} diff --git a/packages/is-shallow-equal/package.json b/packages/is-shallow-equal/package.json index a4b3883e3330c..0f3cc26ba8fa1 100644 --- a/packages/is-shallow-equal/package.json +++ b/packages/is-shallow-equal/package.json @@ -19,6 +19,12 @@ "bugs": { "url": "https://github.com/WordPress/gutenberg/issues" }, + "files": [ + "lib", + "build-types", + "*.js", + "*.md" + ], "main": "lib/index.js", "types": "build-types", "sideEffects": false, From 448fd2f7a690fddfba3dc92fa9740bd0930b4424 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Sun, 22 Mar 2020 19:01:28 +0100 Subject: [PATCH 45/65] Proposal: Use root ts project --- bin/packages/build-types.js | 34 ------------- package.json | 4 +- packages/README.md | 99 ++++++++++++++++++------------------- tsconfig.json | 15 ++++++ 4 files changed, 66 insertions(+), 86 deletions(-) delete mode 100644 bin/packages/build-types.js create mode 100644 tsconfig.json diff --git a/bin/packages/build-types.js b/bin/packages/build-types.js deleted file mode 100644 index 400b5d794720b..0000000000000 --- a/bin/packages/build-types.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * External dependencies - */ -const execa = require( 'execa' ); -const glob = require( 'fast-glob' ); -const path = require( 'path' ); - -/* eslint-disable no-console */ - -const tscPath = path.resolve( - __dirname, - '..', - '..', - 'node_modules', - '.bin', - 'tsc' -); - -function main() { - const packagesWithTs = glob.sync( 'packages/*/tsconfig.json', { - cwd: path.resolve( __dirname, '..', '..' ), - } ); - const projectPaths = packagesWithTs.map( ( tsconfigPath ) => - path.dirname( tsconfigPath ) - ); - - const args = [ '--build', ...projectPaths ]; - - execa.sync( tscPath, args, { stdio: 'inherit' } ); -} - -main(); - -/* eslint-enable no-console */ diff --git a/package.json b/package.json index 6cbd887da08f5..0c443b372d2c9 100644 --- a/package.json +++ b/package.json @@ -177,10 +177,10 @@ }, "scripts": { "prebuild": "npm run check-engines", - "clean:packages": "rimraf ./packages/*/build ./packages/*/build-* ./packages/*/node_modules ./packages/*/tsconfig.tsbuildinfo", + "clean:packages": "rimraf './packages/*/@(build|build-module|build-style)' && tsc --build --clean", "prebuild:packages": "npm run clean:packages && lerna run build", "build:packages": "npm run build:package-types && node ./bin/packages/build.js", - "build:package-types": "node ./bin/packages/build-types.js", + "build:package-types": "tsc --build --verbose", "build": "npm run build:packages && wp-scripts build", "check-engines": "wp-scripts check-engines", "check-licenses": "concurrently \"wp-scripts check-licenses --prod --gpl2\" \"wp-scripts check-licenses --dev\"", diff --git a/packages/README.md b/packages/README.md index 05a8fe9e9a12d..af9be77ff1419 100644 --- a/packages/README.md +++ b/packages/README.md @@ -7,46 +7,44 @@ This repository uses [lerna] to manage WordPress modules and publish them as pac When creating a new package, you need to provide at least the following: 1. `package.json` based on the template: - ```json - { - "name": "@wordpress/package-name", - "version": "1.0.0-beta.0", - "description": "Package description.", - "author": "The WordPress Contributors", - "license": "GPL-2.0-or-later", - "keywords": [ - "wordpress" - ], - "homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/package-name/README.md", - "repository": { - "type": "git", - "url": "https://github.com/WordPress/gutenberg.git" - }, - "bugs": { - "url": "https://github.com/WordPress/gutenberg/issues" - }, - "main": "build/index.js", - "module": "build-module/index.js", - "react-native": "src/index", - "dependencies": { - "@babel/runtime": "^7.8.3" - }, - "publishConfig": { - "access": "public" - } - } - ``` - This assumes that your code is located in the `src` folder and will be transpiled with `Babel`. + ```json + { + "name": "@wordpress/package-name", + "version": "1.0.0-beta.0", + "description": "Package description.", + "author": "The WordPress Contributors", + "license": "GPL-2.0-or-later", + "keywords": [ "wordpress" ], + "homepage": "https://github.com/WordPress/gutenberg/tree/master/packages/package-name/README.md", + "repository": { + "type": "git", + "url": "https://github.com/WordPress/gutenberg.git" + }, + "bugs": { + "url": "https://github.com/WordPress/gutenberg/issues" + }, + "main": "build/index.js", + "module": "build-module/index.js", + "react-native": "src/index", + "dependencies": { + "@babel/runtime": "^7.8.3" + }, + "publishConfig": { + "access": "public" + } + } + ``` + This assumes that your code is located in the `src` folder and will be transpiled with `Babel`. 2. `.npmrc` file which disables creating `package-lock.json` file for the package: - ``` - package-lock=false - ``` + ``` + package-lock=false + ``` 3. `README.md` file containing at least: - - Package name - - Package description - - Installation details - - Usage example - - `Code is Poetry` logo (`

Code is Poetry.

`) + - Package name + - Package description + - Installation details + - Usage example + - `Code is Poetry` logo (`

Code is Poetry.

`) ## Managing Dependencies @@ -57,7 +55,7 @@ There are two types of dependencies that you might want to add to one of the exi Production dependencies are stored in the `dependencies` section of the package’s `package.json` file. #### Adding New Dependencies - + The simplest way to add a production dependency to one of the packages is to run a very convenient [lerna add](https://github.com/lerna/lerna/tree/master/commands/add#readme) command from the root of the project. _Example:_ @@ -91,9 +89,10 @@ Next, you need to run `npm install` in the root of the project to ensure that `p #### Updating Existing Dependencies This is the most confusing part of working with [lerna] which causes a lot of hassles for contributors. The most successful strategy so far is to do the following: - 1. First, remove the existing dependency as described in the previous section. - 2. Next, add the same dependency back as described in the first section of this chapter. This time it wil get the latest version applied unless you enforce a different version explicitly. - + +1. First, remove the existing dependency as described in the previous section. +2. Next, add the same dependency back as described in the first section of this chapter. This time it wil get the latest version applied unless you enforce a different version explicitly. + ### Development Dependencies In contrast to production dependencies, development dependencies shouldn't be stored in individual WordPress packages. Instead they should be installed in the project's `package.json` file using the usual `npm install` command. In effect, all development tools are configured to work with every package at the same time to ensure they share the same characteristics and integrate correctly with each other. @@ -119,16 +118,16 @@ _Example:_ ### Bug Fix -- Fixed an off-by-one error with the `sum` function. +- Fixed an off-by-one error with the `sum` function. ``` There are a number of common release subsections you can follow. Each is intended to align to a specific meaning in the context of the [Semantic Versioning (`semver`) specification](https://semver.org/) the project adheres to. It is important that you describe your changes accurately, since this is used in the packages release process to help determine the version of the next release. -- "Breaking Change" - A backwards-incompatible change which requires specific attention of the impacted developers to reconcile (requires a major version bump). -- "New Feature" - The addition of a new backwards-compatible function or feature to the existing public API (requires a minor verison bump). -- "Enhancement" - Backwards-compatible improvements to existing functionality (requires a minor version bump). -- "Bug Fix" - Resolutions to existing buggy behavior (requires a patch version bump). -- "Internal" - Changes which do not have an impact on the public interface or behavior of the module (requires a patch version bump). +- "Breaking Change" - A backwards-incompatible change which requires specific attention of the impacted developers to reconcile (requires a major version bump). +- "New Feature" - The addition of a new backwards-compatible function or feature to the existing public API (requires a minor verison bump). +- "Enhancement" - Backwards-compatible improvements to existing functionality (requires a minor version bump). +- "Bug Fix" - Resolutions to existing buggy behavior (requires a patch version bump). +- "Internal" - Changes which do not have an impact on the public interface or behavior of the module (requires a patch version bump). While other section naming can be used when appropriate, it's important that are expressed clearly to avoid confusion for both the packages releaser and third-party consumers. @@ -206,8 +205,8 @@ Gutenberg uses TypeScript for several reasons, including: Gutenberg uses TypeScript by running the TypeScript compiler (`tsc`) on select packages. These packages benefit from type checking and produced type declarations in the published packages. -To opt-in to TypeScript tooling, packages should include a `tsconfig.json` file in the package root. -The presence of the `tsconfig.json` file indicates to our build system that the package has opted-in and will be included in the TypeScript build process. +To opt-in to TypeScript tooling, packages should include a `tsconfig.json` file in the package root and add an entry to the root `tsconfig.json` references. +The changes will indicate that the package has opted-in and will be included in the TypeScript build process. A `tsconfig.json` file should look like the following (comments are not necessary): diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000000..2bd29d31753a6 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,15 @@ +{ + "references": [ + { "path": "packages/a11y" }, + { "path": "packages/blob" }, + { "path": "packages/dom-ready" }, + { "path": "packages/i18n" }, + { "path": "packages/is-shallow-equal" }, + { "path": "packages/priority-queue" }, + { "path": "packages/project-management-automation" }, + { "path": "packages/token-list" }, + { "path": "packages/url" }, + { "path": "packages/warning" } + ], + "files": [] +} From ad9f5bc818aa40d6da59a104d42e215888b1c700 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 25 Mar 2020 23:14:07 +0100 Subject: [PATCH 46/65] Use double quotes in package scripts --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c443b372d2c9..f26761266ee81 100644 --- a/package.json +++ b/package.json @@ -177,7 +177,7 @@ }, "scripts": { "prebuild": "npm run check-engines", - "clean:packages": "rimraf './packages/*/@(build|build-module|build-style)' && tsc --build --clean", + "clean:packages": "rimraf \"./packages/*/@(build|build-module|build-style)\" && tsc --build --clean", "prebuild:packages": "npm run clean:packages && lerna run build", "build:packages": "npm run build:package-types && node ./bin/packages/build.js", "build:package-types": "tsc --build --verbose", From 7e9a6e1718e29f162cc861fb4ad0c2b5ddcf4862 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 25 Mar 2020 23:14:24 +0100 Subject: [PATCH 47/65] Only clean types on publish --- package.json | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index f26761266ee81..4792149067436 100644 --- a/package.json +++ b/package.json @@ -177,7 +177,8 @@ }, "scripts": { "prebuild": "npm run check-engines", - "clean:packages": "rimraf \"./packages/*/@(build|build-module|build-style)\" && tsc --build --clean", + "clean:packages": "rimraf \"./packages/*/@(build|build-module|build-style)\"", + "clean:package-types": "tsc --build --clean", "prebuild:packages": "npm run clean:packages && lerna run build", "build:packages": "npm run build:package-types && node ./bin/packages/build.js", "build:package-types": "tsc --build --verbose", @@ -207,9 +208,9 @@ "package-plugin": "./bin/build-plugin-zip.sh", "pot-to-php": "./bin/pot-to-php.js", "publish:check": "lerna updated", - "publish:dev": "npm run build:packages && lerna publish --dist-tag next", - "publish:legacy": "npm run build:packages && lerna publish --dist-tag legacy", - "publish:prod": "npm run build:packages && lerna publish", + "publish:dev": "npm run clean:package-types && npm run build:packages && lerna publish --dist-tag next", + "publish:legacy": "npm run clean:package-types && npm run build:packages && lerna publish --dist-tag legacy", + "publish:prod": "npm run clean:package-types && npm run build:packages && lerna publish", "test": "npm run lint && npm run test-unit", "test-e2e": "wp-scripts test-e2e --config packages/e2e-tests/jest.config.js", "test-e2e:watch": "npm run test-e2e -- --watch", From e2d8f8675f22b8dc8c3c4fe897581db626f4331f Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 25 Mar 2020 23:16:45 +0100 Subject: [PATCH 48/65] Run lint-stage via npm script --- bin/packages/lint-staged-typecheck.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/packages/lint-staged-typecheck.js b/bin/packages/lint-staged-typecheck.js index a3d8577ad4c45..bdba2ae99ff74 100644 --- a/bin/packages/lint-staged-typecheck.js +++ b/bin/packages/lint-staged-typecheck.js @@ -9,7 +9,6 @@ const execa = require( 'execa' ); /* eslint-disable no-console */ const repoRoot = path.join( __dirname, '..', '..' ); -const tscPath = path.join( repoRoot, 'node_modules', '.bin', 'tsc' ); // lint-staged passes full paths to staged changes const changedFiles = process.argv.slice( 2 ); @@ -25,7 +24,7 @@ const changedPackages = _.uniq( ); try { - execa.sync( tscPath, [ '--build', ...changedPackages ] ); + execa.sync( 'npm', [ 'run', 'build:package-types', ...changedPackages ] ); } catch ( err ) { console.error( err.message ); process.exitCode = 1; From 9151cd19dc5e7080fcbc0cbb59309cabef151e5e Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 25 Mar 2020 23:21:12 +0100 Subject: [PATCH 49/65] Remove is-shallow-equal/{arrays,objects} support --- packages/is-shallow-equal/arrays.js | 1 - packages/is-shallow-equal/objects.js | 1 - 2 files changed, 2 deletions(-) delete mode 100644 packages/is-shallow-equal/arrays.js delete mode 100644 packages/is-shallow-equal/objects.js diff --git a/packages/is-shallow-equal/arrays.js b/packages/is-shallow-equal/arrays.js deleted file mode 100644 index e6fc3dc754c5e..0000000000000 --- a/packages/is-shallow-equal/arrays.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require( './lib/arrays.js' ); diff --git a/packages/is-shallow-equal/objects.js b/packages/is-shallow-equal/objects.js deleted file mode 100644 index dc5b2405779df..0000000000000 --- a/packages/is-shallow-equal/objects.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = require( './lib/objects.js' ); From 70b1c2e21e99caf7cdd7175e646eb6fc9ce22e5f Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 25 Mar 2020 23:25:39 +0100 Subject: [PATCH 50/65] Proposal: Check all types on lint-staged --- bin/packages/lint-staged-typecheck.js | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/bin/packages/lint-staged-typecheck.js b/bin/packages/lint-staged-typecheck.js index bdba2ae99ff74..9722f8c56bbe5 100644 --- a/bin/packages/lint-staged-typecheck.js +++ b/bin/packages/lint-staged-typecheck.js @@ -1,33 +1,13 @@ /** * External dependencies */ -const _ = require( 'lodash' ); -const path = require( 'path' ); -const fs = require( 'fs' ); const execa = require( 'execa' ); /* eslint-disable no-console */ - -const repoRoot = path.join( __dirname, '..', '..' ); - -// lint-staged passes full paths to staged changes -const changedFiles = process.argv.slice( 2 ); - -// Transform changed files to package directories containing tsconfig.json -const changedPackages = _.uniq( - changedFiles.map( ( fullPath ) => { - const relativePath = path.relative( repoRoot, fullPath ); - return path.join( ...relativePath.split( path.sep ).slice( 0, 2 ) ); - } ) -).filter( ( packageRoot ) => - fs.existsSync( path.join( packageRoot, 'tsconfig.json' ) ) -); - try { - execa.sync( 'npm', [ 'run', 'build:package-types', ...changedPackages ] ); + execa.sync( 'npm', [ 'run', 'build:package-types' ] ); } catch ( err ) { console.error( err.message ); process.exitCode = 1; } - /* eslint-enable no-console */ From ad17ba1322280a857b8c8d418c9f858f7aaf7795 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 25 Mar 2020 23:30:12 +0100 Subject: [PATCH 51/65] Drop tsc verbose build --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4792149067436..097edf97aa642 100644 --- a/package.json +++ b/package.json @@ -181,7 +181,7 @@ "clean:package-types": "tsc --build --clean", "prebuild:packages": "npm run clean:packages && lerna run build", "build:packages": "npm run build:package-types && node ./bin/packages/build.js", - "build:package-types": "tsc --build --verbose", + "build:package-types": "tsc --build", "build": "npm run build:packages && wp-scripts build", "check-engines": "wp-scripts check-engines", "check-licenses": "concurrently \"wp-scripts check-licenses --prod --gpl2\" \"wp-scripts check-licenses --dev\"", From 1251ec65a50a4ecc3d115a61f0f9463b64724d4c Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Wed, 25 Mar 2020 23:35:54 +0100 Subject: [PATCH 52/65] Fix types in token-list --- packages/token-list/src/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/token-list/src/index.js b/packages/token-list/src/index.js index eaa5e892ddf1c..41f84b47fcc92 100644 --- a/packages/token-list/src/index.js +++ b/packages/token-list/src/index.js @@ -19,14 +19,17 @@ export default class TokenList { // Disable reason: These are type hints on the class. /* eslint-disable no-unused-expressions */ - /** @type string */ + /** @type {string} */ this._currentValue; - /** @type string[] */ + /** @type {string[]} */ this._valueAsArray; /* eslint-enable no-unused-expressions */ } + // Disable reason: JSDoc lint doesn't understand TypeScript types + /* eslint-disable jsdoc/valid-types */ + /** * @param {Parameters['entries']>} args */ @@ -55,6 +58,8 @@ export default class TokenList { return this._valueAsArray.values( ...args ); } + /* eslint-enable jsdoc/valid-types */ + /** * Returns the associated set as string. * From 8dffe92dbd4abd3f0469de844239e5ae3a1c51d7 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 26 Mar 2020 16:53:24 +0100 Subject: [PATCH 53/65] Explain lint-staged script with a comment --- bin/packages/lint-staged-typecheck.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/bin/packages/lint-staged-typecheck.js b/bin/packages/lint-staged-typecheck.js index 9722f8c56bbe5..83fc5970c4a13 100644 --- a/bin/packages/lint-staged-typecheck.js +++ b/bin/packages/lint-staged-typecheck.js @@ -5,6 +5,13 @@ const execa = require( 'execa' ); /* eslint-disable no-console */ try { + // This trivial command is necessary to invoke `tsc` via `lint-staged` + // + // `lint-staged` passes changed files to the script. That would result in + // attempting to run `tsc --build path/to/changed/file.js`, which does not + // correspond to a project (a directory with a `tsconfig.json` files)! + // + // Run here to ignore changed files. execa.sync( 'npm', [ 'run', 'build:package-types' ] ); } catch ( err ) { console.error( err.message ); From 0236148217a9e6b9fa7655c1b954c93fb960b360 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 26 Mar 2020 17:11:09 +0100 Subject: [PATCH 54/65] Restore bin typechecking --- bin/tsconfig.json | 12 ++++++++++++ tsconfig.base.json | 1 + tsconfig.json | 1 + 3 files changed, 14 insertions(+) create mode 100644 bin/tsconfig.json diff --git a/bin/tsconfig.json b/bin/tsconfig.json new file mode 100644 index 0000000000000..1f450c35cb1d3 --- /dev/null +++ b/bin/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "../tsconfig.base.json", + "compilerOptions": { + "module": "commonjs", + "esModuleInterop": true, + "target": "ES6", + "lib": [ "ES6", "ES2020.string" ], + "rootDir": ".", + "outDir": ".cache" + }, + "files": [ "./api-docs/update-api-docs.js" ] +} diff --git a/tsconfig.base.json b/tsconfig.base.json index 4d9920e600802..8ee1f8b3d415b 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -26,6 +26,7 @@ /* Module Resolution Options */ "moduleResolution": "node", + /* This needs to be false so our types are possible to consume without setting this */ "esModuleInterop": false, "resolveJsonModule": true diff --git a/tsconfig.json b/tsconfig.json index 2bd29d31753a6..d5c7494798745 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,5 +1,6 @@ { "references": [ + { "path": "bin" }, { "path": "packages/a11y" }, { "path": "packages/blob" }, { "path": "packages/dom-ready" }, From 89a0540839f97c744ac1482511e9fcc7797ae0a9 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 26 Mar 2020 17:12:50 +0100 Subject: [PATCH 55/65] Comment cache outdir --- bin/tsconfig.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bin/tsconfig.json b/bin/tsconfig.json index 1f450c35cb1d3..76c43dc3cb114 100644 --- a/bin/tsconfig.json +++ b/bin/tsconfig.json @@ -6,6 +6,10 @@ "target": "ES6", "lib": [ "ES6", "ES2020.string" ], "rootDir": ".", + + // We're not interested in the output, but we must generate + // something as part of a composite project. Use the + // ignored `.cache` file to hide tsbuildinfo and d.ts files. "outDir": ".cache" }, "files": [ "./api-docs/update-api-docs.js" ] From 9c5782c43d6021de3455ff561d979086e623e91f Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 26 Mar 2020 17:16:26 +0100 Subject: [PATCH 56/65] Remove redundant entry from is-shallow-equal files --- packages/is-shallow-equal/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/is-shallow-equal/package.json b/packages/is-shallow-equal/package.json index 0f3cc26ba8fa1..32219eda44981 100644 --- a/packages/is-shallow-equal/package.json +++ b/packages/is-shallow-equal/package.json @@ -22,7 +22,6 @@ "files": [ "lib", "build-types", - "*.js", "*.md" ], "main": "lib/index.js", From c4516f33a6d6c37029e6d4899dd3a1d5e7b80223 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Thu, 26 Mar 2020 17:25:17 +0100 Subject: [PATCH 57/65] Disable declarationMap for bin --- bin/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/tsconfig.json b/bin/tsconfig.json index 76c43dc3cb114..aab14da756163 100644 --- a/bin/tsconfig.json +++ b/bin/tsconfig.json @@ -6,6 +6,7 @@ "target": "ES6", "lib": [ "ES6", "ES2020.string" ], "rootDir": ".", + "declarationMap": false, // We're not interested in the output, but we must generate // something as part of a composite project. Use the From adb7a78c808f29154e5e356523b8bd0dc9a9d775 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 27 Mar 2020 11:02:11 +0100 Subject: [PATCH 58/65] Add types to package.json lint --- packages/npm-package-json-lint-config/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/npm-package-json-lint-config/index.js b/packages/npm-package-json-lint-config/index.js index e8fbd3eebdcec..831970c59bf3a 100644 --- a/packages/npm-package-json-lint-config/index.js +++ b/packages/npm-package-json-lint-config/index.js @@ -57,6 +57,7 @@ const defaultConfig = { 'main', 'module', 'react-native', + 'types', 'bin', 'dependencies', 'devDependencies', From a213ca951ca8ff4923d509a7c3874fc77777cc56 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 27 Mar 2020 11:05:25 +0100 Subject: [PATCH 59/65] Update is-shallow-equal benchmarks --- packages/is-shallow-equal/benchmark/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/is-shallow-equal/benchmark/index.js b/packages/is-shallow-equal/benchmark/index.js index 5506e53206e12..5779f87688eae 100644 --- a/packages/is-shallow-equal/benchmark/index.js +++ b/packages/is-shallow-equal/benchmark/index.js @@ -16,10 +16,10 @@ const afterArrayUnequal = [ 1, 2, 3, 4, 5, 'Unequal', 7 ]; [ [ '@wordpress/is-shallow-equal (type specific)', - require( '../objects' ), - require( '../arrays' ), + require( '..' ).isShallowEqualObjects, + require( '..' ).isShallowEqualArrays, ], - [ '@wordpress/is-shallow-equal', require( '../' ) ], + [ '@wordpress/is-shallow-equal', require( '..' ) ], [ 'shallowequal', require( 'shallowequal' ) ], [ 'shallow-equal (type specific)', From 6ee66b50f8427c2bc5d9deee607fc20ce0eae7ec Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 27 Mar 2020 11:08:42 +0100 Subject: [PATCH 60/65] Update is-shallow-equal tests --- packages/is-shallow-equal/test/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/is-shallow-equal/test/index.js b/packages/is-shallow-equal/test/index.js index 3ec86ed352928..66bf538552c64 100644 --- a/packages/is-shallow-equal/test/index.js +++ b/packages/is-shallow-equal/test/index.js @@ -1,9 +1,10 @@ /** * Internal dependencies */ -import isShallowEqual from '../'; -import isShallowEqualArrays from '../arrays'; -import isShallowEqualObjects from '../objects'; +import isShallowEqual, { + isShallowEqualArrays, + isShallowEqualObjects, +} from '..'; describe( 'isShallowEqual', () => { it( 'returns false if of different types', () => { From 4d95dc02b29ac6e404ace31c7e94bb95c1a1646a Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 27 Mar 2020 11:09:49 +0100 Subject: [PATCH 61/65] Revert "Explain lint-staged script with a comment" This reverts commit 8dffe92dbd4abd3f0469de844239e5ae3a1c51d7. --- bin/packages/lint-staged-typecheck.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/bin/packages/lint-staged-typecheck.js b/bin/packages/lint-staged-typecheck.js index 83fc5970c4a13..9722f8c56bbe5 100644 --- a/bin/packages/lint-staged-typecheck.js +++ b/bin/packages/lint-staged-typecheck.js @@ -5,13 +5,6 @@ const execa = require( 'execa' ); /* eslint-disable no-console */ try { - // This trivial command is necessary to invoke `tsc` via `lint-staged` - // - // `lint-staged` passes changed files to the script. That would result in - // attempting to run `tsc --build path/to/changed/file.js`, which does not - // correspond to a project (a directory with a `tsconfig.json` files)! - // - // Run here to ignore changed files. execa.sync( 'npm', [ 'run', 'build:package-types' ] ); } catch ( err ) { console.error( err.message ); From bc0eac366e7ceae4be5f9adc02fb664d4e7d5401 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 27 Mar 2020 11:10:11 +0100 Subject: [PATCH 62/65] Revert "Proposal: Check all types on lint-staged" This reverts commit 70b1c2e21e99caf7cdd7175e646eb6fc9ce22e5f. --- bin/packages/lint-staged-typecheck.js | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/bin/packages/lint-staged-typecheck.js b/bin/packages/lint-staged-typecheck.js index 9722f8c56bbe5..bdba2ae99ff74 100644 --- a/bin/packages/lint-staged-typecheck.js +++ b/bin/packages/lint-staged-typecheck.js @@ -1,13 +1,33 @@ /** * External dependencies */ +const _ = require( 'lodash' ); +const path = require( 'path' ); +const fs = require( 'fs' ); const execa = require( 'execa' ); /* eslint-disable no-console */ + +const repoRoot = path.join( __dirname, '..', '..' ); + +// lint-staged passes full paths to staged changes +const changedFiles = process.argv.slice( 2 ); + +// Transform changed files to package directories containing tsconfig.json +const changedPackages = _.uniq( + changedFiles.map( ( fullPath ) => { + const relativePath = path.relative( repoRoot, fullPath ); + return path.join( ...relativePath.split( path.sep ).slice( 0, 2 ) ); + } ) +).filter( ( packageRoot ) => + fs.existsSync( path.join( packageRoot, 'tsconfig.json' ) ) +); + try { - execa.sync( 'npm', [ 'run', 'build:package-types' ] ); + execa.sync( 'npm', [ 'run', 'build:package-types', ...changedPackages ] ); } catch ( err ) { console.error( err.message ); process.exitCode = 1; } + /* eslint-enable no-console */ From 3fbe6f2bff2105c88376829b91f508c1e7a93fc9 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 27 Mar 2020 11:18:24 +0100 Subject: [PATCH 63/65] Revert "Run lint-stage via npm script" This reverts commit e2d8f8675f22b8dc8c3c4fe897581db626f4331f. --- bin/packages/lint-staged-typecheck.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/packages/lint-staged-typecheck.js b/bin/packages/lint-staged-typecheck.js index bdba2ae99ff74..a3d8577ad4c45 100644 --- a/bin/packages/lint-staged-typecheck.js +++ b/bin/packages/lint-staged-typecheck.js @@ -9,6 +9,7 @@ const execa = require( 'execa' ); /* eslint-disable no-console */ const repoRoot = path.join( __dirname, '..', '..' ); +const tscPath = path.join( repoRoot, 'node_modules', '.bin', 'tsc' ); // lint-staged passes full paths to staged changes const changedFiles = process.argv.slice( 2 ); @@ -24,7 +25,7 @@ const changedPackages = _.uniq( ); try { - execa.sync( 'npm', [ 'run', 'build:package-types', ...changedPackages ] ); + execa.sync( tscPath, [ '--build', ...changedPackages ] ); } catch ( err ) { console.error( err.message ); process.exitCode = 1; From a9c8577e73bb98c9a38208718e20d1899a655515 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 27 Mar 2020 11:25:16 +0100 Subject: [PATCH 64/65] Log type errors with lint-staged --- bin/packages/lint-staged-typecheck.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/packages/lint-staged-typecheck.js b/bin/packages/lint-staged-typecheck.js index a3d8577ad4c45..579f154e3df34 100644 --- a/bin/packages/lint-staged-typecheck.js +++ b/bin/packages/lint-staged-typecheck.js @@ -27,7 +27,7 @@ const changedPackages = _.uniq( try { execa.sync( tscPath, [ '--build', ...changedPackages ] ); } catch ( err ) { - console.error( err.message ); + console.error( err.stdout ); process.exitCode = 1; } From dfd2bc1969f0e8e29cfea28c6d67d97ae7500686 Mon Sep 17 00:00:00 2001 From: Jon Surrell Date: Fri, 27 Mar 2020 11:57:30 +0100 Subject: [PATCH 65/65] Update changelog for affected packages - New feature for packages with type declarations - Breaking change for is-shallow-equal direct imports of arrays/objects - Breaking change for `types` order in npm-package-json-lint-config --- packages/a11y/CHANGELOG.md | 6 ++++++ packages/blob/CHANGELOG.md | 6 ++++++ packages/dom-ready/CHANGELOG.md | 6 ++++++ packages/i18n/CHANGELOG.md | 4 +++- packages/is-shallow-equal/CHANGELOG.md | 12 ++++++++++++ packages/npm-package-json-lint-config/CHANGELOG.md | 8 +++++++- packages/priority-queue/CHANGELOG.md | 4 ++++ packages/project-management-automation/CHANGELOG.md | 6 ++++++ packages/token-list/CHANGELOG.md | 6 ++++++ packages/url/CHANGELOG.md | 4 ++++ packages/warning/CHANGELOG.md | 4 ++++ 11 files changed, 64 insertions(+), 2 deletions(-) diff --git a/packages/a11y/CHANGELOG.md b/packages/a11y/CHANGELOG.md index 6d3354f059cc8..b1c90b9bd0c75 100644 --- a/packages/a11y/CHANGELOG.md +++ b/packages/a11y/CHANGELOG.md @@ -1,3 +1,9 @@ +## Master + +### New feature + +- Include TypeScript type declarations ([#18942](https://github.com/WordPress/gutenberg/pull/18942)) + ## 2.0.0 (2018-09-05) ### Breaking Change diff --git a/packages/blob/CHANGELOG.md b/packages/blob/CHANGELOG.md index 1288967c3cfdb..03731fb72850f 100644 --- a/packages/blob/CHANGELOG.md +++ b/packages/blob/CHANGELOG.md @@ -1,3 +1,9 @@ +## Master + +### New feature + +- Include TypeScript type declarations ([#18942](https://github.com/WordPress/gutenberg/pull/18942)) + ## 2.1.0 (2018-10-19) ### New Features diff --git a/packages/dom-ready/CHANGELOG.md b/packages/dom-ready/CHANGELOG.md index 116d21d37d421..1d18cce33a0aa 100644 --- a/packages/dom-ready/CHANGELOG.md +++ b/packages/dom-ready/CHANGELOG.md @@ -1,3 +1,9 @@ +## Master + +### New feature + +- Include TypeScript type declarations ([#18942](https://github.com/WordPress/gutenberg/pull/18942)) + ## 2.0.0 (2018-09-05) ### Breaking Change diff --git a/packages/i18n/CHANGELOG.md b/packages/i18n/CHANGELOG.md index 700b3b520eefb..e9b5255dae532 100644 --- a/packages/i18n/CHANGELOG.md +++ b/packages/i18n/CHANGELOG.md @@ -2,7 +2,9 @@ ### New Feature -- Add `isRTL` function (#20298) +- Add `isRTL` function ([#20298](https://github.com/WordPress/gutenberg/pull/20298)) +- Include TypeScript type declarations ([#18942](https://github.com/WordPress/gutenberg/pull/18942)) + ## 3.1.0 (2018-11-15) diff --git a/packages/is-shallow-equal/CHANGELOG.md b/packages/is-shallow-equal/CHANGELOG.md index 17019daee1ea6..4eb1d049e0079 100644 --- a/packages/is-shallow-equal/CHANGELOG.md +++ b/packages/is-shallow-equal/CHANGELOG.md @@ -1,3 +1,15 @@ +## Master + +### Breaking change + +- Restructure package moving source files into `lib` directory. Direct imports of + `@wordpress/is-shallow-equal/arrays` and `@wordpress/is-shallow-equal/objects` were never + officially supported and have been removed. ([#18942](https://github.com/WordPress/gutenberg/pull/18942)) + +### New feature + +- Include TypeScript type declarations ([#18942](https://github.com/WordPress/gutenberg/pull/18942)) + ## 1.5.0 (2019-08-05) ### Bug Fixes diff --git a/packages/npm-package-json-lint-config/CHANGELOG.md b/packages/npm-package-json-lint-config/CHANGELOG.md index 945e31866bbe8..c00529998a1ff 100644 --- a/packages/npm-package-json-lint-config/CHANGELOG.md +++ b/packages/npm-package-json-lint-config/CHANGELOG.md @@ -1,6 +1,12 @@ +## Master + +### Breaking Change + +- Add `types` to the order of preferred properties. ([#18942](https://github.com/WordPress/gutenberg/pull/18942)) + ## 2.0.0 (2019-06-12) -### Braking Change +### Breaking Change - Added `type` and `react-native` to the order of preferred properties. diff --git a/packages/priority-queue/CHANGELOG.md b/packages/priority-queue/CHANGELOG.md index e4a76269c9ca8..9232755f3aa4d 100644 --- a/packages/priority-queue/CHANGELOG.md +++ b/packages/priority-queue/CHANGELOG.md @@ -1,5 +1,9 @@ ## Master +### New feature + +- Include TypeScript type declarations ([#18942](https://github.com/WordPress/gutenberg/pull/18942)) + ## 1.5.0 (2020-02-04) ### Bug Fixes diff --git a/packages/project-management-automation/CHANGELOG.md b/packages/project-management-automation/CHANGELOG.md index 2c2284ae8eebf..c7363d0d38510 100644 --- a/packages/project-management-automation/CHANGELOG.md +++ b/packages/project-management-automation/CHANGELOG.md @@ -1,3 +1,9 @@ +## Master + +### New feature + +- Include TypeScript type declarations ([#18942](https://github.com/WordPress/gutenberg/pull/18942)) + ## 1.0.0 (2019-08-29) - Initial release. diff --git a/packages/token-list/CHANGELOG.md b/packages/token-list/CHANGELOG.md index 4f09e8ebd8395..48bb8d1722464 100644 --- a/packages/token-list/CHANGELOG.md +++ b/packages/token-list/CHANGELOG.md @@ -1,3 +1,9 @@ +## Master + +### New feature + +- Include TypeScript type declarations ([#18942](https://github.com/WordPress/gutenberg/pull/18942)) + ## 1.1.0 (2018-11-20) ### Enhancements diff --git a/packages/url/CHANGELOG.md b/packages/url/CHANGELOG.md index 2845b6c35e4ac..bf543a6242284 100644 --- a/packages/url/CHANGELOG.md +++ b/packages/url/CHANGELOG.md @@ -1,5 +1,9 @@ ## Master +### New feature + +- Include TypeScript type declarations ([#18942](https://github.com/WordPress/gutenberg/pull/18942)) + ### Bug Fixes - `getQueryString` now correctly considers hash fragments when considering whether to return a query string. Previously, `getQueryString( 'https://example.com/#?foo' )` would wrongly return `'foo'` as its result. A hash fragment is always the last segment of a URL, and the querystring must always precede it ([see reference specification](https://url.spec.whatwg.org/#absolute-url-with-fragment-string)). diff --git a/packages/warning/CHANGELOG.md b/packages/warning/CHANGELOG.md index 15517d8f1ce7c..e6a9454a3e0ff 100644 --- a/packages/warning/CHANGELOG.md +++ b/packages/warning/CHANGELOG.md @@ -1,5 +1,9 @@ ## Master +### New feature + +- Include TypeScript type declarations ([#18942](https://github.com/WordPress/gutenberg/pull/18942)) + ## 1.0.0 (2020-02-04) Initial release.