Skip to content

Commit

Permalink
Tools: Update TypeScript to the 4.4.x version (#34373)
Browse files Browse the repository at this point in the history
* Tools: Update TypeScript to the 4.4.x version
See: https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/

* Fix unknow type in catch variables

* Use unknown errors in input-field state

* skipLibCheck to prevent Reakit type errors from causing issues

* Use lodash DebouncedFunc for throttled/debounced functions

* Restore FireFox-only caretPositionFromPoint type

See https://unpkg.com/browse/@types/[email protected]/index.d.ts

* Disable useUnknownInCatchVariables for lazy-import

* Fix unknown catch variable in project-management-automation

* Relax the check in catch clause for hasWordPressProfile call

Co-authored-by: Jon Surrell <[email protected]>
  • Loading branch information
gziolo and sirreal authored Sep 1, 2021
1 parent 003d83c commit bdb9272
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 95 deletions.
4 changes: 3 additions & 1 deletion bin/plugin/commands/changelog.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
110 changes: 52 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
5 changes: 1 addition & 4 deletions packages/components/src/input-control/reducer/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/input-control/reducer/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/input-control/reducer/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion packages/components/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" },
Expand Down
4 changes: 2 additions & 2 deletions packages/compose/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ _Parameters_

_Returns_

- `TFunc & import('lodash').Cancelable`: Debounced function.
- `import('lodash').DebouncedFunc<TFunc>`: Debounced function.

### useFocusOnMount

Expand Down Expand Up @@ -452,7 +452,7 @@ _Parameters_

_Returns_

- `TFunc & import('lodash').Cancelable`: Throttled function.
- `import('lodash').DebouncedFunc<TFunc>`: Throttled function.

### useViewportMatch

Expand Down
4 changes: 2 additions & 2 deletions packages/compose/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
"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",
"@wordpress/element": "file:../element",
"@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",
Expand Down
2 changes: 1 addition & 1 deletion packages/compose/src/hooks/use-debounce/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<TFunc>} Debounced function.
*/
export default function useDebounce( fn, wait, options ) {
/* eslint-enable jsdoc/valid-types */
Expand Down
2 changes: 1 addition & 1 deletion packages/compose/src/hooks/use-throttle/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<TFunc>} Throttled function.
*/
export default function useThrottle( fn, wait, options ) {
const throttled = useMemoOne( () => throttle( fn, wait, options ), [
Expand Down
7 changes: 6 additions & 1 deletion packages/dom/src/dom/caret-range-from-point.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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
*/
Loading

0 comments on commit bdb9272

Please sign in to comment.