Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Typescript 5.1 #52621

Merged
merged 6 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,13 @@ module.exports = {
],
},
],
'@typescript-eslint/consistent-type-imports': [
'error',
{
prefer: 'type-imports',
disallowTypeAnnotations: false,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We frequently import type annotations via JSDoc in Gutenberg, so we need to keep this setting off :)

},
],
'no-restricted-syntax': [
'error',
// NOTE: We can't include the forward slash in our regex or
Expand Down
529 changes: 430 additions & 99 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
"strip-json-comments": "5.0.0",
"style-loader": "3.2.1",
"terser-webpack-plugin": "5.3.9",
"typescript": "4.9.5",
"typescript": "5.1.6",
"uglify-js": "3.13.7",
"uuid": "8.3.0",
"wd": "1.12.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import { __ } from '@wordpress/i18n';
import Button from '../../button';
import Tooltip from '../../tooltip';
import { View } from '../../view';
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect } from '../../ui/context';
import { useBorderBoxControlLinkedButton } from './hook';

import type { LinkedButtonProps } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { useMemo } from '@wordpress/element';
* Internal dependencies
*/
import * as styles from '../styles';
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { useContextSystem } from '../../ui/context';
import { useCx } from '../../utils/hooks/use-cx';

import type { LinkedButtonProps } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { useMergeRefs } from '@wordpress/compose';
import BorderBoxControlVisualizer from '../border-box-control-visualizer';
import { BorderControl } from '../../border-control';
import { Grid } from '../../grid';
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect } from '../../ui/context';
import { useBorderBoxControlSplitControls } from './hook';

import type { BorderControlProps } from '../../border-control/types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { useMemo } from '@wordpress/element';
* Internal dependencies
*/
import * as styles from '../styles';
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { useContextSystem } from '../../ui/context';
import { useCx } from '../../utils/';

import type { SplitControlsProps } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { __ } from '@wordpress/i18n';
* Internal dependencies
*/
import { View } from '../../view';
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect } from '../../ui/context';
import { useBorderBoxControlVisualizer } from './hook';

import type { VisualizerProps } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { useMemo } from '@wordpress/element';
* Internal dependencies
*/
import * as styles from '../styles';
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { useContextSystem } from '../../ui/context';
import { useCx } from '../../utils';

import type { VisualizerProps } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import { BorderControl } from '../../border-control';
import { StyledLabel } from '../../base-control/styles/base-control-styles';
import { View } from '../../view';
import { VisuallyHidden } from '../../visually-hidden';
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect } from '../../ui/context';
import { useBorderBoxControl } from './hook';

import type { BorderBoxControlProps } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
isCompleteBorder,
isEmptyBorder,
} from '../utils';
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { useContextSystem } from '../../ui/context';
import { useCx } from '../../utils/hooks/use-cx';

import type { Border } from '../../border-control/types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ import ColorPalette from '../../color-palette';
import Dropdown from '../../dropdown';
import { HStack } from '../../h-stack';
import { VStack } from '../../v-stack';
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect } from '../../ui/context';
import { useBorderControlDropdown } from './hook';
import { StyledLabel } from '../../base-control/styles/base-control-styles';
import DropdownContentWrapper from '../../dropdown/dropdown-content-wrapper';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { useMemo } from '@wordpress/element';
*/
import * as styles from '../styles';
import { parseQuantityAndUnitFromRawValue } from '../../unit-control/utils';
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { useContextSystem } from '../../ui/context';
import { useCx } from '../../utils/hooks/use-cx';

import type { DropdownProps } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { StyledLabel } from '../../base-control/styles/base-control-styles';
import { View } from '../../view';
import { Flex } from '../../flex';
import { VisuallyHidden } from '../../visually-hidden';
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect } from '../../ui/context';
import { useBorderControlStylePicker } from './hook';

import type { LabelProps, StylePickerProps } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { useMemo } from '@wordpress/element';
* Internal dependencies
*/
import * as styles from '../styles';
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { useContextSystem } from '../../ui/context';
import { useCx } from '../../utils/hooks/use-cx';

import type { StylePickerProps } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import { HStack } from '../../h-stack';
import { StyledLabel } from '../../base-control/styles/base-control-styles';
import { View } from '../../view';
import { VisuallyHidden } from '../../visually-hidden';
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect } from '../../ui/context';
import { useBorderControl } from './hook';

import type { BorderControlProps, LabelProps } from '../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { useCallback, useMemo, useState } from '@wordpress/element';
*/
import * as styles from '../styles';
import { parseQuantityAndUnitFromRawValue } from '../../unit-control/utils';
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { useContextSystem } from '../../ui/context';
import { useCx } from '../../utils/hooks/use-cx';

import type { Border, BorderControlProps } from '../types';
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/card/card-body/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type { ForwardedRef } from 'react';
/**
* Internal dependencies
*/
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect } from '../../ui/context';
import { Scrollable } from '../../scrollable';
import { View } from '../../view';
import { useCardBody } from './hook';
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/card/card-body/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { useContextSystem } from '../../ui/context';
import * as styles from '../styles';
import { useCx } from '../../utils/hooks/use-cx';
import type { BodyProps } from '../types';
Expand Down
6 changes: 4 additions & 2 deletions packages/components/src/card/card-divider/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import type { ForwardedRef } from 'react';
/**
* Internal dependencies
*/
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import { Divider, DividerProps } from '../../divider';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect } from '../../ui/context';
import type { DividerProps } from '../../divider';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nit, but I've found it a little bit easier to read when import type statements are grouped below the last of the import statement.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea, but since these were all (more or less) automatic fixes, I'm not keen on going through all the files and reordering them. Would you want to add this as a separate lint rule?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we don't enforce sorting by an ESLint rule in Gutenberg, I'd abstain from this unless we can automatically sort them. It's a pretty minor deal too, feel free to ignore 😉

import { Divider } from '../../divider';
import { useCardDivider } from './hook';

function UnconnectedCardDivider(
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/card/card-divider/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { useContextSystem } from '../../ui/context';
import * as styles from '../styles';
import { useCx } from '../../utils/hooks/use-cx';
import type { DividerProps } from '../../divider';
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/card/card-footer/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type { ForwardedRef } from 'react';
/**
* Internal dependencies
*/
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect } from '../../ui/context';
import { Flex } from '../../flex';
import { useCardFooter } from './hook';
import type { FooterProps } from '../types';
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/card/card-footer/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { useContextSystem } from '../../ui/context';
import * as styles from '../styles';
import { useCx } from '../../utils/hooks/use-cx';
import type { FooterProps } from '../types';
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/card/card-header/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type { ForwardedRef } from 'react';
/**
* Internal dependencies
*/
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect } from '../../ui/context';
import { Flex } from '../../flex';
import { useCardHeader } from './hook';
import type { HeaderProps } from '../types';
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/card/card-header/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { useContextSystem } from '../../ui/context';
import * as styles from '../styles';
import { useCx } from '../../utils/hooks/use-cx';
import type { HeaderProps } from '../types';
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/card/card-media/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type { ForwardedRef } from 'react';
/**
* Internal dependencies
*/
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect } from '../../ui/context';
import { View } from '../../view';
import { useCardMedia } from './hook';
import type { MediaProps } from '../types';
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/card/card-media/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import { useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { useContextSystem } from '../../ui/context';
import * as styles from '../styles';
import { useCx } from '../../utils/hooks/use-cx';
import type { MediaProps } from '../types';
Expand Down
7 changes: 2 additions & 5 deletions packages/components/src/card/card/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ import { useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import {
contextConnect,
ContextSystemProvider,
WordPressComponentProps,
} from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect, ContextSystemProvider } from '../../ui/context';
import { Elevation } from '../../elevation';
import { View } from '../../view';
import * as styles from '../styles';
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/card/card/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import { useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import { useContextSystem, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { useContextSystem } from '../../ui/context';
import { useSurface } from '../../surface';
import * as styles from '../styles';
import { useCx } from '../../utils/hooks/use-cx';
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/color-picker/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* External dependencies
*/
import type { ForwardedRef } from 'react';
import { colord, extend, Colord } from 'colord';
import type { Colord } from 'colord';
import { colord, extend } from 'colord';
import namesPlugin from 'colord/plugins/names';

/**
Expand Down
7 changes: 2 additions & 5 deletions packages/components/src/confirm-dialog/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ import { useCallback, useEffect, useRef, useState } from '@wordpress/element';
*/
import Modal from '../modal';
import type { OwnProps, DialogInputEvent } from './types';
import {
useContextSystem,
contextConnect,
WordPressComponentProps,
} from '../ui/context';
import type { WordPressComponentProps } from '../ui/context';
import { useContextSystem, contextConnect } from '../ui/context';
import { Flex } from '../flex';
import Button from '../button';
import { Text } from '../text';
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/date-time/time/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ import { HStack } from '../../h-stack';
import { Spacer } from '../../spacer';
import type { InputChangeCallback } from '../../input-control/types';
import type { InputState } from '../../input-control/reducer/state';
import type { InputAction } from '../../input-control/reducer/actions';
import {
COMMIT,
InputAction,
PRESS_DOWN,
PRESS_UP,
} from '../../input-control/reducer/actions';
Expand Down
7 changes: 2 additions & 5 deletions packages/components/src/divider/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ import type { ForwardedRef } from 'react';
/**
* Internal dependencies
*/
import {
contextConnect,
useContextSystem,
WordPressComponentProps,
} from '../ui/context';
import type { WordPressComponentProps } from '../ui/context';
import { contextConnect, useContextSystem } from '../ui/context';
import { DividerView } from './styles';
import type { DividerProps } from './types';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import type { ForwardedRef } from 'react';
/**
* Internal dependencies
*/
import {
WordPressComponentProps,
contextConnect,
useContextSystem,
} from '../ui/context';
import type { WordPressComponentProps } from '../ui/context';
import { contextConnect, useContextSystem } from '../ui/context';
import { DropdownContentWrapperDiv } from './styles';
import type { DropdownContentWrapperProps } from './types';

Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/elevation/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type { ForwardedRef } from 'react';
/**
* Internal dependencies
*/
import { contextConnect, WordPressComponentProps } from '../ui/context';
import type { WordPressComponentProps } from '../ui/context';
import { contextConnect } from '../ui/context';
import { View } from '../view';
import { useElevation } from './hook';
import type { ElevationProps } from './types';
Expand Down
6 changes: 4 additions & 2 deletions packages/components/src/elevation/hook.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* External dependencies
*/
import { css, SerializedStyles } from '@emotion/react';
import type { SerializedStyles } from '@emotion/react';
import { css } from '@emotion/react';

/**
* WordPress dependencies
Expand All @@ -11,7 +12,8 @@ import { useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import { useContextSystem, WordPressComponentProps } from '../ui/context';
import type { WordPressComponentProps } from '../ui/context';
import { useContextSystem } from '../ui/context';
import * as styles from './styles';
import { CONFIG, reduceMotion } from '../utils';
import { useCx } from '../utils/hooks/use-cx';
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/flex/flex-block/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ import type { ForwardedRef } from 'react';
/**
* Internal dependencies
*/
import { contextConnect, WordPressComponentProps } from '../../ui/context';
import type { WordPressComponentProps } from '../../ui/context';
import { contextConnect } from '../../ui/context';
import { View } from '../../view';
import type { FlexBlockProps } from '../types';
import { useFlexBlock } from './hook';
Expand Down
Loading
Loading