diff --git a/bin/plugin/commands/changelog.js b/bin/plugin/commands/changelog.js index 73d8afdae4edf1..dca2ce62406e7a 100644 --- a/bin/plugin/commands/changelog.js +++ b/bin/plugin/commands/changelog.js @@ -780,7 +780,9 @@ async function createChangelog( settings ) { try { changelog = await getChangelog( settings ); } catch ( error ) { - changelog = formats.error( error.stack ); + if ( error instanceof Error ) { + changelog = formats.error( error.stack ); + } } log( changelog ); diff --git a/package-lock.json b/package-lock.json index c3c1f113627cdb..691657bafb2674 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16403,16 +16403,13 @@ } }, "@types/classnames": { - "version": "2.2.10", - "resolved": "https://registry.npmjs.org/@types/classnames/-/classnames-2.2.10.tgz", - "integrity": "sha512-1UzDldn9GfYYEsWWnn/P4wkTlkZDH7lDb0wBMGbtIQc9zXEQq7FlKBdZUn6OBqD8sKZZ2RQO2mAjGpXiDGoRmQ==", - "dev": true - }, - "@types/clipboard": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/@types/clipboard/-/clipboard-2.0.1.tgz", - "integrity": "sha512-gJJX9Jjdt3bIAePQRRjYWG20dIhAgEqonguyHxXuqALxsoDsDLimihqrSg8fXgVTJ4KZCzkfglKtwsh/8dLfbA==", - "dev": true + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/@types/classnames/-/classnames-2.3.1.tgz", + "integrity": "sha512-zeOWb0JGBoVmlQoznvqXbE0tEC/HONsnoUNH19Hc96NFsTAwTXbTqb8FMYkru1F/iqp7a18Ws3nWJvtA1sHD1A==", + "dev": true, + "requires": { + "classnames": "*" + } }, "@types/color-convert": { "version": "2.0.0", @@ -16430,9 +16427,9 @@ "dev": true }, "@types/eslint": { - "version": "6.8.0", - "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-6.8.0.tgz", - "integrity": "sha512-hqzmggoxkOubpgTdcOltkfc5N8IftRJqU70d1jbOISjjZVPvjcr+CLi2CI70hx1SUIRkLgpglTy9w28nGe2Hsw==", + "version": "7.28.0", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-7.28.0.tgz", + "integrity": "sha512-07XlgzX0YJUn4iG1ocY4IX9DzKSmMGUs6ESKlxWhZRaa0fatIWaHWUVapcuGa8r5HFnTqzj+4OCjd5f7EZ/i/A==", "dev": true, "requires": { "@types/estree": "*", @@ -16450,9 +16447,9 @@ } }, "@types/estree": { - "version": "0.0.44", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.44.tgz", - "integrity": "sha512-iaIVzr+w2ZJ5HkidlZ3EJM8VTZb2MJLCjw3V+505yVts0gRC4UMvjw0d1HPtGqI/HQC/KdsYtayfzl+AXY2R8g==", + "version": "0.0.50", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.50.tgz", + "integrity": "sha512-C6N5s2ZFtuZRj54k2/zyRhNDjJwwcViAM3Nbm8zjBpbqAdZ00mr0CFxvSKeO8Y/e03WVFLpQMdHYVfUd6SB+Hw==", "dev": true }, "@types/events": { @@ -16501,9 +16498,9 @@ } }, "@types/highlight-words-core": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@types/highlight-words-core/-/highlight-words-core-1.2.0.tgz", - "integrity": "sha512-yy+e7t3P5ABzT/Bl0Wy0hxworXGKKSJVQljaUQxco9ddXY5OZVbRm+yyzZAPBhP4C7KwfkZRRhNOCYkLbloFYw==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@types/highlight-words-core/-/highlight-words-core-1.2.1.tgz", + "integrity": "sha512-9VZUA5omXBfn+hDxFjUDu1FOJTBM3LmvqfDey+Z6Aa8B8/JmF5SMj6FBrjfgJ/Q3YXOZd3qyTDfJyMZSs/wCUA==", "dev": true }, "@types/html-minifier-terser": { @@ -16575,9 +16572,9 @@ } }, "@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==" + "version": "4.14.172", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.172.tgz", + "integrity": "sha512-/BHF5HAx3em7/KkzVKm3LrsD6HZAXuXO1AJZQ3cRRBZj4oHZDviWPYu0aEplAqDFNHZPW6d3G7KN+ONcCCC7pw==" }, "@types/markdown-to-jsx": { "version": "6.11.3", @@ -16667,9 +16664,9 @@ "dev": true }, "@types/npm-package-arg": { - "version": "6.1.0", - "resolved": "https://registry.npmjs.org/@types/npm-package-arg/-/npm-package-arg-6.1.0.tgz", - "integrity": "sha512-vbt5fb0y1svMhu++1lwtKmZL76d0uPChFlw7kEzyUmTwfmpHRcFb8i0R8ElT69q/L+QLgK2hgECivIAvaEDwag==", + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/@types/npm-package-arg/-/npm-package-arg-6.1.1.tgz", + "integrity": "sha512-452/1Kp9IdM/oR10AyqAgZOxUt7eLbm+EMJ194L6oarMYdZNiFIFAOJ7IIr0OrZXTySgfHjJezh2oiyk2kc3ag==", "dev": true }, "@types/npmlog": { @@ -16696,9 +16693,9 @@ "dev": true }, "@types/prettier": { - "version": "1.19.0", - "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-1.19.0.tgz", - "integrity": "sha512-gDE8JJEygpay7IjA/u3JiIURvwZW08f0cZSZLAzFoX/ZmeqvS0Sqv+97aKuHpNsalAMMhwPe+iAS6fQbfmbt7A==", + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.3.2.tgz", + "integrity": "sha512-eI5Yrz3Qv4KPUa/nSIAi0h+qX0XyewOliug5F2QAtuRg6Kjg6jfmxe1GIwoIRhZspD1A0RP8ANrPwvEXXtRFog==", "dev": true }, "@types/pretty-hrtime": { @@ -16719,9 +16716,9 @@ "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==", + "version": "6.9.7", + "resolved": "https://registry.npmjs.org/@types/qs/-/qs-6.9.7.tgz", + "integrity": "sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==", "dev": true }, "@types/reach__router": { @@ -16767,9 +16764,9 @@ } }, "@types/requestidlecallback": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@types/requestidlecallback/-/requestidlecallback-0.3.1.tgz", - "integrity": "sha512-BnnRkgWYijCIndUn+LgoqKHX/hNpJC5G03B9y7mZya/C2gUQTSn75fEj3ZP1/Rl2E6EYeXh2/7/8UNEZ4X7HuQ==", + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/@types/requestidlecallback/-/requestidlecallback-0.3.4.tgz", + "integrity": "sha512-aTSyiZuRemRLTQkJPb25L7A4/eR2Teo5l4yJ1V6P3+MFxEZckTDkNKNtr/V1zEOMzS6H8DgxF22U6jPAPrzQvw==", "dev": true }, "@types/responselike": { @@ -16782,13 +16779,10 @@ } }, "@types/semver": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.2.0.tgz", - "integrity": "sha512-TbB0A8ACUWZt3Y6bQPstW9QNbhNeebdgLX4T/ZfkrswAfUzRiXrgd9seol+X379Wa589Pu4UEx9Uok0D4RjRCQ==", - "dev": true, - "requires": { - "@types/node": "*" - } + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-D/2EJvAlCEtYFEYmmlGwbGXuK886HzyCc3nZX/tkFTQdEU8jZDAgiv08P162yB17y4ZXZoq7yFAnW4GDBb9Now==", + "dev": true }, "@types/source-list-map": { "version": "0.1.2", @@ -16818,9 +16812,9 @@ } }, "@types/tinycolor2": { - "version": "1.4.2", - "resolved": "https://registry.npmjs.org/@types/tinycolor2/-/tinycolor2-1.4.2.tgz", - "integrity": "sha512-PeHg/AtdW6aaIO2a+98Xj7rWY4KC1E6yOy7AFknJQ7VXUGNrMlyxDFxJo7HqLtjQms/ZhhQX52mLVW/EX3JGOw==", + "version": "1.4.3", + "resolved": "https://registry.npmjs.org/@types/tinycolor2/-/tinycolor2-1.4.3.tgz", + "integrity": "sha512-Kf1w9NE5HEgGxCRyIcRXR/ZYtDv0V8FVPtYHwLxl0O+maGX0erE77pQlD0gpP+/KByMZ87mOA79SjifhSB3PjQ==", "dev": true }, "@types/uglify-js": { @@ -16847,9 +16841,9 @@ "dev": true }, "@types/uuid": { - "version": "8.3.0", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.0.tgz", - "integrity": "sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ==", + "version": "8.3.1", + "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.1.tgz", + "integrity": "sha512-Y2mHTRAbqfFkpjldbkHGY8JIzRN6XqYRliG8/24FcHm2D2PwW24fl5xMRTVGdrb7iMrwCaIEbLWerGIkXuFWVg==", "dev": true }, "@types/vfile": { @@ -18182,7 +18176,7 @@ "version": "file:packages/compose", "requires": { "@babel/runtime": "^7.13.10", - "@types/lodash": "4.14.149", + "@types/lodash": "^4.14.172", "@types/mousetrap": "^1.6.8", "@wordpress/deprecated": "file:packages/deprecated", "@wordpress/dom": "file:packages/dom", @@ -18190,7 +18184,7 @@ "@wordpress/is-shallow-equal": "file:packages/is-shallow-equal", "@wordpress/keycodes": "file:packages/keycodes", "@wordpress/priority-queue": "file:packages/priority-queue", - "clipboard": "^2.0.1", + "clipboard": "^2.0.8", "lodash": "^4.17.21", "mousetrap": "^1.6.5", "react-resize-aware": "^3.1.0", @@ -30500,9 +30494,9 @@ "dev": true }, "clipboard": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.1.tgz", - "integrity": "sha512-7yhQBmtN+uYZmfRjjVjKa0dZdWuabzpSKGtyQZN+9C8xlC788SSJjOHWh7tzurfwTqTD5UDYAhIv5fRJg3sHjQ==", + "version": "2.0.8", + "resolved": "https://registry.npmjs.org/clipboard/-/clipboard-2.0.8.tgz", + "integrity": "sha512-Y6WO0unAIQp5bLmk1zdThRhgJt/x3ks6f30s3oE3H1mgIEU33XyQjEf8gsf6DxC7NPX8Y1SsNWjUjL/ywLnnbQ==", "requires": { "good-listener": "^1.2.2", "select": "^1.1.2", @@ -59097,9 +59091,9 @@ "dev": true }, "tiny-emitter": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.0.2.tgz", - "integrity": "sha512-2NM0auVBGft5tee/OxP4PI3d8WItkDM+fPnaRAVo6xTDI2knbz9eC5ArWGqtGlYqiH3RU5yMpdyTTO7MguC4ow==" + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/tiny-emitter/-/tiny-emitter-2.1.0.tgz", + "integrity": "sha512-NB6Dk1A9xgQPMoGqC5CVXn123gWyte215ONT5Pp5a0yt4nlEoO1ZWeCwpncaekPHXO60i47ihFnZPiRPjRMq4Q==" }, "tiny-lr": { "version": "1.1.1", @@ -59449,9 +59443,9 @@ } }, "typescript": { - "version": "4.1.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.1.3.tgz", - "integrity": "sha512-B3ZIOf1IKeH2ixgHhj6la6xdwR9QrLC5d1VKeCSY4tvkqhF2eqd9O7txNlS0PO3GrBAFIdr3L1ndNwteUbZLYg==", + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz", + "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==", "dev": true }, "ua-parser-js": { diff --git a/package.json b/package.json index 13696a49f7d48c..6b1d957ec8b053 100644 --- a/package.json +++ b/package.json @@ -106,20 +106,19 @@ "@testing-library/jest-dom": "5.11.9", "@testing-library/react": "11.2.2", "@testing-library/react-native": "7.1.0", - "@types/classnames": "2.2.10", - "@types/clipboard": "2.0.1", - "@types/eslint": "6.8.0", - "@types/estree": "0.0.44", - "@types/highlight-words-core": "1.2.0", - "@types/lodash": "4.14.149", - "@types/npm-package-arg": "6.1.0", - "@types/prettier": "1.19.0", - "@types/qs": "6.9.1", - "@types/requestidlecallback": "0.3.1", - "@types/semver": "7.2.0", + "@types/classnames": "2.3.1", + "@types/eslint": "7.28.0", + "@types/estree": "0.0.50", + "@types/highlight-words-core": "1.2.1", + "@types/lodash": "4.14.172", + "@types/npm-package-arg": "6.1.1", + "@types/prettier": "2.3.2", + "@types/qs": "6.9.7", + "@types/requestidlecallback": "0.3.4", + "@types/semver": "7.3.8", "@types/sprintf-js": "1.1.2", - "@types/tinycolor2": "1.4.2", - "@types/uuid": "8.3.0", + "@types/tinycolor2": "1.4.3", + "@types/uuid": "8.3.1", "@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", @@ -209,7 +208,7 @@ "sprintf-js": "1.1.1", "style-loader": "3.2.1", "terser-webpack-plugin": "5.1.4", - "typescript": "4.1.3", + "typescript": "4.4.2", "uglify-js": "3.13.7", "uuid": "8.3.0", "wd": "1.12.1", diff --git a/packages/components/src/input-control/reducer/actions.ts b/packages/components/src/input-control/reducer/actions.ts index 652e7211e251e4..66ca918de77070 100644 --- a/packages/components/src/input-control/reducer/actions.ts +++ b/packages/components/src/input-control/reducer/actions.ts @@ -44,10 +44,7 @@ export type DragEndAction = Action< typeof DRAG_END, DragProps >; export type DragAction = Action< typeof DRAG, DragProps >; export type ResetAction = Action< typeof RESET, Partial< ValuePayload > >; export type UpdateAction = Action< typeof UPDATE, ValuePayload >; -export type InvalidateAction = Action< - typeof INVALIDATE, - { error: Error | null } ->; +export type InvalidateAction = Action< typeof INVALIDATE, { error: unknown } >; export type ChangeEventAction = | ChangeAction diff --git a/packages/components/src/input-control/reducer/reducer.ts b/packages/components/src/input-control/reducer/reducer.ts index 1aad3f8d3e6725..362739e758a42b 100644 --- a/packages/components/src/input-control/reducer/reducer.ts +++ b/packages/components/src/input-control/reducer/reducer.ts @@ -213,7 +213,7 @@ export function useInputControlStateReducer( * Actions for the reducer */ const change = createChangeEvent( actions.CHANGE ); - const invalidate = ( error: Error, event: SyntheticEvent ) => + const invalidate = ( error: unknown, event: SyntheticEvent ) => dispatch( { type: actions.INVALIDATE, payload: { error, event } } ); const reset = createChangeEvent( actions.RESET ); const commit = createChangeEvent( actions.COMMIT ); diff --git a/packages/components/src/input-control/reducer/state.ts b/packages/components/src/input-control/reducer/state.ts index 9fcbfad2d1ae28..455cce5f00f1da 100644 --- a/packages/components/src/input-control/reducer/state.ts +++ b/packages/components/src/input-control/reducer/state.ts @@ -11,7 +11,7 @@ import type { InputAction } from './actions'; export interface InputState { _event: Event | {}; - error: Error | null; + error: unknown; initialValue?: string; isDirty: boolean; isDragEnabled: boolean; diff --git a/packages/components/tsconfig.json b/packages/components/tsconfig.json index 77809950efbdd5..a0a0e879a3066f 100644 --- a/packages/components/tsconfig.json +++ b/packages/components/tsconfig.json @@ -3,7 +3,10 @@ "compilerOptions": { "rootDir": "src", "declarationDir": "build-types", - "types": [ "gutenberg-env" ] + "types": [ "gutenberg-env" ], + // Some errors in Reakit types with TypeScript 4.3 + // Remove the following line when they've been addressed. + "skipLibCheck": true }, "references": [ { "path": "../compose" }, diff --git a/packages/compose/README.md b/packages/compose/README.md index c66787eb8c3d77..8d918eba025707 100644 --- a/packages/compose/README.md +++ b/packages/compose/README.md @@ -207,7 +207,7 @@ _Parameters_ _Returns_ -- `TFunc & import('lodash').Cancelable`: Debounced function. +- `import('lodash').DebouncedFunc`: Debounced function. ### useFocusOnMount @@ -452,7 +452,7 @@ _Parameters_ _Returns_ -- `TFunc & import('lodash').Cancelable`: Throttled function. +- `import('lodash').DebouncedFunc`: Throttled function. ### useViewportMatch diff --git a/packages/compose/package.json b/packages/compose/package.json index f97c1131b59c47..d1c4efc6294777 100644 --- a/packages/compose/package.json +++ b/packages/compose/package.json @@ -30,7 +30,7 @@ "sideEffects": false, "dependencies": { "@babel/runtime": "^7.13.10", - "@types/lodash": "4.14.149", + "@types/lodash": "^4.14.172", "@types/mousetrap": "^1.6.8", "@wordpress/deprecated": "file:../deprecated", "@wordpress/dom": "file:../dom", @@ -38,7 +38,7 @@ "@wordpress/is-shallow-equal": "file:../is-shallow-equal", "@wordpress/keycodes": "file:../keycodes", "@wordpress/priority-queue": "file:../priority-queue", - "clipboard": "^2.0.1", + "clipboard": "^2.0.8", "lodash": "^4.17.21", "mousetrap": "^1.6.5", "react-resize-aware": "^3.1.0", diff --git a/packages/compose/src/hooks/use-debounce/index.js b/packages/compose/src/hooks/use-debounce/index.js index 374f20a521a5e9..db66e74d590c65 100644 --- a/packages/compose/src/hooks/use-debounce/index.js +++ b/packages/compose/src/hooks/use-debounce/index.js @@ -23,7 +23,7 @@ import { useEffect } from '@wordpress/element'; * @param {TFunc} fn The function to debounce. * @param {number} [wait] The number of milliseconds to delay. * @param {import('lodash').DebounceSettings} [options] The options object. - * @return {TFunc & import('lodash').Cancelable} Debounced function. + * @return {import('lodash').DebouncedFunc} Debounced function. */ export default function useDebounce( fn, wait, options ) { /* eslint-enable jsdoc/valid-types */ diff --git a/packages/compose/src/hooks/use-throttle/index.js b/packages/compose/src/hooks/use-throttle/index.js index 8ad9589d112dec..45fb2696673ae1 100644 --- a/packages/compose/src/hooks/use-throttle/index.js +++ b/packages/compose/src/hooks/use-throttle/index.js @@ -22,7 +22,7 @@ import { useEffect } from '@wordpress/element'; * @param {TFunc} fn The function to throttle. * @param {number} [wait] The number of milliseconds to throttle invocations to. * @param {import('lodash').ThrottleSettings} [options] The options object. See linked documentation for details. - * @return {TFunc & import('lodash').Cancelable} Throttled function. + * @return {import('lodash').DebouncedFunc} Throttled function. */ export default function useThrottle( fn, wait, options ) { const throttled = useMemoOne( () => throttle( fn, wait, options ), [ diff --git a/packages/dom/src/dom/caret-range-from-point.js b/packages/dom/src/dom/caret-range-from-point.js index fb32c15f0f9759..a3f83926f083a2 100644 --- a/packages/dom/src/dom/caret-range-from-point.js +++ b/packages/dom/src/dom/caret-range-from-point.js @@ -4,7 +4,7 @@ * * @see https://developer.mozilla.org/en-US/docs/Web/API/Document/caretRangeFromPoint * - * @param {Document} doc The document of the range. + * @param {DocumentMaybeWithCaretPositionFromPoint} doc The document of the range. * @param {number} x Horizontal position within the current viewport. * @param {number} y Vertical position within the current viewport. * @@ -34,3 +34,8 @@ export default function caretRangeFromPoint( doc, x, y ) { return range; } + +/** + * @typedef {{caretPositionFromPoint?: (x: number, y: number)=> CaretPosition | null} & Document } DocumentMaybeWithCaretPositionFromPoint + * @typedef {{ readonly offset: number; readonly offsetNode: Node; getClientRect(): DOMRect | null; }} CaretPosition + */ diff --git a/packages/i18n/src/sprintf.js b/packages/i18n/src/sprintf.js index 98c4bade268a11..550248a81c9e9e 100644 --- a/packages/i18n/src/sprintf.js +++ b/packages/i18n/src/sprintf.js @@ -28,8 +28,9 @@ export function sprintf( format, ...args ) { try { return sprintfjs.sprintf( format, ...args ); } catch ( error ) { - logErrorOnce( 'sprintf error: \n\n' + error.toString() ); - + if ( error instanceof Error ) { + logErrorOnce( 'sprintf error: \n\n' + error.toString() ); + } return format; } } diff --git a/packages/lazy-import/tsconfig.json b/packages/lazy-import/tsconfig.json index 426ab13d0aa8f6..fd6069e3843aed 100644 --- a/packages/lazy-import/tsconfig.json +++ b/packages/lazy-import/tsconfig.json @@ -2,7 +2,8 @@ "extends": "../../tsconfig.base.json", "compilerOptions": { "rootDir": "lib", - "declarationDir": "build-types" + "declarationDir": "build-types", + "useUnknownInCatchVariables": false }, "include": [ "lib/**/*" ] } diff --git a/packages/project-management-automation/lib/tasks/add-milestone/index.js b/packages/project-management-automation/lib/tasks/add-milestone/index.js index 3f26cd3ed3f31f..1058f6bc9d7a71 100644 --- a/packages/project-management-automation/lib/tasks/add-milestone/index.js +++ b/packages/project-management-automation/lib/tasks/add-milestone/index.js @@ -19,7 +19,7 @@ const DAYS_PER_RELEASE = 14; * Returns true if the given error object represents a duplicate entry error, or * false otherwise. * - * @param {RequestError} requestError Error to test. + * @param {unknown} requestError Error to test. * * @return {boolean} Whether error is a duplicate validation request error. */ @@ -27,7 +27,12 @@ const isDuplicateValidationError = ( requestError ) => { // The included version of RequestError provides no way to access the // full 'errors' array that the github REST API returns. Hopefully they // resolve this soon! - return requestError.message.includes( 'already_exists' ); + const errorMessage = /** @type {undefined | null | {message?: string}} */ ( requestError ) + ?.message; + return ( + typeof errorMessage === 'string' && + errorMessage.includes( 'already_exists' ) + ); }; /** diff --git a/packages/project-management-automation/lib/tasks/first-time-contributor-account-link/index.js b/packages/project-management-automation/lib/tasks/first-time-contributor-account-link/index.js index 9d18ccad467aa8..b60f65d5f5dc05 100644 --- a/packages/project-management-automation/lib/tasks/first-time-contributor-account-link/index.js +++ b/packages/project-management-automation/lib/tasks/first-time-contributor-account-link/index.js @@ -86,9 +86,11 @@ async function firstTimeContributorAccountLink( payload, octokit ) { try { hasProfile = await hasWordPressProfile( author ); } catch ( error ) { - debug( - `first-time-contributor-account-link: Error retrieving from profile API:\n\n${ error.toString() }` - ); + if ( error instanceof Object ) { + debug( + `first-time-contributor-account-link: Error retrieving from profile API:\n\n${ error.toString() }` + ); + } return; }