storybookjs / storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation
https://storybook.js.org
MIT License
84.73k stars 9.33k forks source link

6.4.1-6.4.5 Typescript error, ambivalent exports should be re-named #16888

Closed kliehm closed 2 years ago

kliehm commented 2 years ago

Discussed in https://github.com/storybookjs/storybook/discussions/16887

Originally posted by **kliehm** December 3, 2021 When I build with StencilJs 2.5.2 and Typescript 4.5.2, I get the following Typescript error: ``` [ ERROR ] TypeScript: ./node_modules/@storybook/client-api/dist/ts3.9/index.d.ts:4:1 Module './types' has already exported a member named 'RenderContext'. Consider explicitly re-exporting to resolve the ambiguity. L3: export * from './queryparams'; L4: export * from '@storybook/store'; L5: export { addArgsEnhancer, addArgTypesEnhancer, addDecorator, addLoader, addParameters, setGlobalRender, ClientApi, }; [ ERROR ] TypeScript: ./node_modules/@storybook/client-api/dist/ts3.9/index.d.ts:4:1 Module './types' has already exported a member named 'StorySpecifier'. Consider explicitly re-exporting to resolve the ambiguity. L3: export * from './queryparams'; L4: export * from '@storybook/store'; L5: export { addArgsEnhancer, addArgTypesEnhancer, addDecorator, addLoader, addParameters, setGlobalRender, ClientApi, }; ``` So `types.d.ts` has ``` export declare type StorySpecifier = StoryId | { name: StoryName; kind: StoryKind; } | '*'; export declare type RenderContext = RenderContextWithoutStoryContext & { storyContext: StoryContext; }; ``` while `index.d.ts` is ``` import { ClientApi, addDecorator, addParameters, addLoader, addArgsEnhancer, addArgTypesEnhancer, setGlobalRender } from './ClientApi'; export * from './types'; export * from './queryparams'; export * from '@storybook/store'; export { addArgsEnhancer, addArgTypesEnhancer, addDecorator, addLoader, addParameters, setGlobalRender, ClientApi, }; ``` If you look at `index.d.ts`, there is another import from `ClientApi`, whose members are explicitly exported by name, not by *. I think that's the way to go. Sidenote: It seems that Storybook only implemented Typescript 3.9, perhaps that's why the error didn't occur in your build yet. Also the error appeared with Storybook 6.4.1, it wasn't in 6.3.12.
shilman commented 2 years ago

closing as dupe to #16839

tmeasday commented 2 years ago

Appreciate the detail, thanks @kliehm