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

TypeScript: Migrate @storybook/docs-tools to strict TS #22567

Merged
merged 26 commits into from
Nov 29, 2023

Conversation

efrenaragon96
Copy link
Contributor

Part of #22176

What I did

Migrate @storybook/docs-tools to strict-ts

How to test

Checklist

  • Make sure your changes are tested (stories and/or unit, integration, or end-to-end tests)
  • Make sure to add/update documentation regarding your changes
  • If you are deprecating/removing a feature, make sure to update
    MIGRATION.MD

Maintainers

  • If this PR should be tested against many or all sandboxes,
    make sure to add the ci:merged or ci:daily GH label to it.
  • Make sure this PR contains one of the labels below.

["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]

@efrenaragon96 efrenaragon96 requested a review from a team as a code owner June 5, 2023 19:16
Copy link
Contributor

@kasperpeulen kasperpeulen left a comment

Choose a reason for hiding this comment

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

Something seems to wrong in CI.

@efrenaragon96
Copy link
Contributor Author

Something seems to wrong in CI.

What do you propose? Because the last change isn't rare or complex.

@kasperpeulen kasperpeulen added maintenance User-facing maintenance tasks ci:normal labels Aug 3, 2023
@yannbf
Copy link
Member

yannbf commented Sep 19, 2023

Hey @efrenaragon96 thanks for your contribution! @kasperpeulen would you mind chiming in whenever you have time?

@ndelangen
Copy link
Member

@efrenaragon96 can you check what's going on with these failures:

> nx run @storybook/react:check

src/docs/propTypes/handleProp.test.tsx:86:18 - error TS18047: 'type' is possibly 'null'.

86           expect(type.summary).toBe('MY_LITERAL');
                    ~~~~
src/docs/propTypes/handleProp.test.tsx:87:18 - error TS18047: 'type' is possibly 'null'.

87           expect(type.detail).toBeUndefined();
                    ~~~~
src/docs/propTypes/handleProp.test.tsx:102:18 - error TS18047: 'type' is possibly 'null'.

102           expect(type.summary.replace(/\s/g, '')).toBe(expectedSummary.replace(/\s/g, ''));
                     ~~~~
src/docs/propTypes/handleProp.test.tsx:102:18 - error TS18048: 'type.summary' is possibly 'undefined'.

102           expect(type.summary.replace(/\s/g, '')).toBe(expectedSummary.replace(/\s/g, ''));
                     ~~~~~~~~~~~~
src/docs/propTypes/handleProp.test.tsx:103:18 - error TS18047: 'type' is possibly 'null'.

103           expect(type.detail).toBeUndefined();
                     ~~~~
src/docs/propTypes/handleProp.test.tsx:116:18 - error TS18047: 'type' is possibly 'null'.

116           expect(type.summary).toBe('object');
                     ~~~~
src/docs/propTypes/handleProp.test.tsx:126:18 - error TS18047: 'type' is possibly 'null'.

126           expect(type.detail?.replace(/\s/g, '')).toBe(expectedDetail.replace(/\s/g, ''));
                     ~~~~
src/docs/propTypes/handleProp.test.tsx:139:18 - error TS18047: 'type' is possibly 'null'.

139           expect(type.summary).toBe('object');
                     ~~~~
src/docs/propTypes/handleProp.test.tsx:152:18 - error TS18047: 'type' is possibly 'null'.

152           expect(type.summary).toBe('InlinedFunctionalComponent');
                     ~~~~
src/docs/propTypes/handleProp.test.tsx:158:18 - error TS18047: 'type' is possibly 'null'.

158           expect(type.detail?.replace(/\s/g, '')).toBe(expectedDetail.replace(/\s/g, ''));
                     ~~~~
src/docs/propTypes/handleProp.test.tsx:171:18 - error TS18047: 'type' is possibly 'null'.

171           expect(type.summary).toBe('element');
                     ~~~~
src/docs/propTypes/handleProp.test.tsx:176:18 - error TS18047: 'type' is possibly 'null'.

176           expect(type.detail?.replace(/\s/g, '')).toBe(expectedDetail.replace(/\s/g, ''));
                     ~~~~
src/docs/propTypes/handleProp.test.tsx:189:18 - error TS18047: 'type' is possibly 'null'.

189           expect(type.summary).toBe('element');
                     ~~~~
src/docs/propTypes/handleProp.test.tsx:195:18 - error TS18047: 'type' is possibly 'null'.

195           expect(type.detail?.replace(/\s/g, '')).toBe(expectedDetail.replace(/\s/g, ''));
                     ~~~~
src/docs/propTypes/handleProp.test.tsx:209:20 - error TS18047: 'type' is possibly 'null'.

209             expect(type.summary).toBe('custom');
                       ~~~~
src/docs/propTypes/handleProp.test.tsx:210:20 - error TS18047: 'type' is possibly 'null'.

210             expect(type.detail).toBe(
                       ~~~~
src/docs/propTypes/handleProp.test.tsx:225:20 - error TS18047: 'type' is possibly 'null'.

225             expect(type.summary).toBe('Symbol("Hey!")');
                       ~~~~
src/docs/propTypes/handleProp.test.tsx:226:20 - error TS18047: 'type' is possibly 'null'.

226             expect(type.detail).toBeUndefined();
                       ~~~~
src/docs/propTypes/handleProp.test.tsx:240:16 - error TS18047: 'type' is possibly 'null'.

240         expect(type.summary).toBe('custom');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:264:16 - error TS18047: 'type' is possibly 'null'.

264         expect(type.summary).toBe(x);
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:285:14 - error TS18047: 'type' is possibly 'null'.

285       expect(type.summary.replace(/\s/g, '')).toBe(expectedSummary.replace(/\s/g, ''));
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:285:14 - error TS18048: 'type.summary' is possibly 'undefined'.

285       expect(type.summary.replace(/\s/g, '')).toBe(expectedSummary.replace(/\s/g, ''));
                 ~~~~~~~~~~~~
src/docs/propTypes/handleProp.test.tsx:286:14 - error TS18047: 'type' is possibly 'null'.

286       expect(type.detail).toBeUndefined();
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:324:14 - error TS18047: 'type' is possibly 'null'.

324       expect(type.summary).toBe('object');
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:335:14 - error TS18047: 'type' is possibly 'null'.

335       expect(type.detail?.replace(/\s/g, '')).toBe(expectedDetail.replace(/\s/g, ''));
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:359:14 - error TS18047: 'type' is possibly 'null'.

359       expect(type.summary).toBe('object');
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:381:14 - error TS18047: 'type' is possibly 'null'.

381       expect(type.summary).toBe("'News' | 'Photos'");
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:405:14 - error TS18047: 'type' is possibly 'null'.

405       expect(type.summary).toBe('object | object');
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:417:14 - error TS18047: 'type' is possibly 'null'.

417       expect(type.detail?.replace(/\s/g, '')).toBe(expectedDetail.replace(/\s/g, ''));
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:439:14 - error TS18047: 'type' is possibly 'null'.

439       expect(type.summary).toBe('{ text: string } | { foo: string }');
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:461:14 - error TS18047: 'type' is possibly 'null'.

461       expect(type.summary).toBe('object | object');
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:484:14 - error TS18047: 'type' is possibly 'null'.

484       expect(type.summary).toBe('element | ClassComponent');
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:494:14 - error TS18047: 'type' is possibly 'null'.

494       expect(type.detail?.replace(/\s/g, '')).toBe(expectedDetail.replace(/\s/g, ''));
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:507:16 - error TS18047: 'type' is possibly 'null'.

507         expect(type.summary).toBe('func');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:520:16 - error TS18047: 'type' is possibly 'null'.

520         expect(type.summary).toBe('func');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:533:16 - error TS18047: 'type' is possibly 'null'.

533         expect(type.summary).toBe('(event, data) => string');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:547:14 - error TS18047: 'type' is possibly 'null'.

547       expect(type.summary).toBe('Set');
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:563:16 - error TS18047: 'type' is possibly 'null'.

563         expect(type.summary).toBe('objectOf(number)');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:564:16 - error TS18047: 'type' is possibly 'null'.

564         expect(type.detail).toBeUndefined();
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:580:16 - error TS18047: 'type' is possibly 'null'.

580         expect(type.summary).toBe('objectOf(NAMED_OBJECT)');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:581:16 - error TS18047: 'type' is possibly 'null'.

581         expect(type.detail).toBeUndefined();
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:597:16 - error TS18047: 'type' is possibly 'null'.

597         expect(type.summary).toBe('objectOf({ foo: string })');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:598:16 - error TS18047: 'type' is possibly 'null'.

598         expect(type.detail).toBeUndefined();
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:614:16 - error TS18047: 'type' is possibly 'null'.

614         expect(type.summary).toBe('objectOf(object)');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:623:16 - error TS18047: 'type' is possibly 'null'.

623         expect(type.detail?.replace(/\s/g, '')).toBe(expectedDetail.replace(/\s/g, ''));
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:639:16 - error TS18047: 'type' is possibly 'null'.

639         expect(type.summary).toBe('objectOf(object)');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:660:16 - error TS18047: 'type' is possibly 'null'.

660         expect(type.summary).toBe('objectOf({ foo: string })');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:661:16 - error TS18047: 'type' is possibly 'null'.

661         expect(type.detail).toBeUndefined();
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:694:16 - error TS18047: 'type' is possibly 'null'.

694         expect(type.summary).toBe('objectOf(object)');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:703:16 - error TS18047: 'type' is possibly 'null'.

703         expect(type.detail?.replace(/\s/g, '')).toBe(expectedDetail.replace(/\s/g, ''));
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:730:16 - error TS18047: 'type' is possibly 'null'.

730         expect(type.summary).toBe('objectOf(object)');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:752:14 - error TS18047: 'type' is possibly 'null'.

752       expect(type.summary).toBe('string | Set');
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:753:14 - error TS18047: 'type' is possibly 'null'.

753       expect(type.detail).toBeUndefined();
                 ~~~~
src/docs/propTypes/handleProp.test.tsx:769:16 - error TS18047: 'type' is possibly 'null'.

769         expect(type.summary).toBe('number[]');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:770:16 - error TS18047: 'type' is possibly 'null'.

770         expect(type.detail).toBeUndefined();
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:786:16 - error TS18047: 'type' is possibly 'null'.

786         expect(type.summary).toBe('NAMED_OBJECT[]');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:787:16 - error TS18047: 'type' is possibly 'null'.

787         expect(type.detail).toBeUndefined();
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:803:16 - error TS18047: 'type' is possibly 'null'.

803         expect(type.summary).toBe('[{ foo: string }]');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:804:16 - error TS18047: 'type' is possibly 'null'.

804         expect(type.detail).toBeUndefined();
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:820:16 - error TS18047: 'type' is possibly 'null'.

820         expect(type.summary).toBe('object[]');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:831:16 - error TS18047: 'type' is possibly 'null'.

831         expect(type.detail?.replace(/\s/g, '')).toBe(expectedDetail.replace(/\s/g, ''));
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:847:16 - error TS18047: 'type' is possibly 'null'.

847         expect(type.summary).toBe('object[]');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:868:16 - error TS18047: 'type' is possibly 'null'.

868         expect(type.summary).toBe('[{ foo: string }]');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:869:16 - error TS18047: 'type' is possibly 'null'.

869         expect(type.detail).toBeUndefined();
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:910:16 - error TS18047: 'type' is possibly 'null'.

910         expect(type.summary).toBe('object[]');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:921:16 - error TS18047: 'type' is possibly 'null'.

921         expect(type.detail?.replace(/\s/g, '')).toBe(expectedDetail.replace(/\s/g, ''));
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:948:16 - error TS18047: 'type' is possibly 'null'.

948         expect(type.summary).toBe('object[]');
                   ~~~~
src/docs/propTypes/handleProp.test.tsx:976:14 - error TS18048: 'defaultValue.summary' is possibly 'undefined'.

976       expect(defaultValue?.summary.replace(/\s/g, '')).toBe(expectedSummary.replace(/\s/g, ''));
                 ~~~~~~~~~~~~~~~~~~~~~
src/docs/propTypes/rawDefaultPropResolvers.ts:13:21 - error TS18047: 'type' is possibly 'null'.

13   const isElement = type.summary === 'element' || type.summary === 'elementType';
                       ~~~~
src/docs/propTypes/rawDefaultPropResolvers.ts:13:51 - error TS18047: 'type' is possibly 'null'.

13   const isElement = type.summary === 'element' || type.summary === 'elementType';
                                                     ~~~~
src/docs/typeScript/handleProp.test.tsx:88:14 - error TS18048: 'defaultValue.summary' is possibly 'undefined'.

88       expect(defaultValue?.summary.replace(/\s/g, '')).toBe(expectedSummary.replace(/\s/g, ''));
                ~~~~~~~~~~~~~~~~~~~~~


> nx run @storybook/vue:check

src/docs/extractArgTypes.ts(21,9): error TS2339: Property 'summary' does not exist on type 'PropSummaryValue | null'.
src/docs/extractArgTypes.ts(24,17): error TS2769: No overload matches this call.
  Overload 1 of 4, '(target: {}, source: { name: string; value: any[]; summary: any; detail?: string | undefined; }): { name: string; value: any[]; summary: any; detail?: string | undefined; }', gave the following error.
    Argument of type 'PropSummaryValue | null' is not assignable to parameter of type '{}'.
      Type 'null' is not assignable to type '{}'.
  Overload 2 of 4, '(target: object, ...sources: any[]): any', gave the following error.
    Argument of type 'PropSummaryValue | null' is not assignable to parameter of type 'object'.
      Type 'null' is not assignable to type 'object'.

🙏

@valentinpalkovic valentinpalkovic removed their request for review November 28, 2023 09:02
@ndelangen ndelangen changed the title Migrate @storybook/docs-tools to strict TS Maintenence: Migrate @storybook/docs-tools to strict TS Nov 28, 2023
Copy link

Updated and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Packages Version New capabilities Transitives Size Publisher
@rollup/pluginutils 5.0.5...5.1.0 None +0/-0 57.1 kB shellscape

🚮 Removed packages: @angular-devkit/core@16.2.4, @storybook/client-logger@7.5.3, @storybook/theming@7.5.3

@ndelangen ndelangen merged commit 9fecce2 into storybookjs:next Nov 29, 2023
49 of 51 checks passed
@github-actions github-actions bot mentioned this pull request Nov 29, 2023
36 tasks
@shilman shilman changed the title Maintenence: Migrate @storybook/docs-tools to strict TS TypeScript: Migrate @storybook/docs-tools to strict TS Dec 5, 2023
@github-actions github-actions bot mentioned this pull request Dec 7, 2023
44 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:normal maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants