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

6.2.5 addon-link - LinkTo - New TypeScript Errors #14539

Closed
contrast-jeremiahp opened this issue Apr 9, 2021 · 9 comments · Fixed by #17434
Closed

6.2.5 addon-link - LinkTo - New TypeScript Errors #14539

contrast-jeremiahp opened this issue Apr 9, 2021 · 9 comments · Fixed by #17434

Comments

@contrast-jeremiahp
Copy link

contrast-jeremiahp commented Apr 9, 2021

Describe the bug
Following the addon-link documentation captured here: https://www.npmjs.com/package/@storybook/addon-links

LinkTo in @storybook/addon-link@6.2.5 now results in a TypeScript error:

  • JSX element type 'LinkTo' does not have any construct or call signatures.

This issue did not exist in @storybook/addon-link@6.1.21

To Reproduce
Steps to reproduce the behavior:

  1. Install @storybook/addon-link@6.1.21 as a dependency in a TypeScript project
  2. Write a simple TypeScript component such as
    image
  3. Notice NO TypeScript Errors
  4. Upgrade dependency to @storybook/addon-link@6.2.25
  5. See TypeScript error
    image

Expected behavior
TypeScript errors do not occur in addon-links@6.2+

Workaround

  • Add a ts-ignore comment
    image

Additional Notes:

  • Using 6.2.5, the code import usesnode_modules/@storybook/addon-links/react.d.ts
  • Using 6.1.21, the code import uses node_modules/@storybook/addon-links/react.js
@contrast-jeremiahp contrast-jeremiahp changed the title 6.2.5 addon-link - LinkTo TypeScript Errors (did not occur in 6.1.21) 6.2.5 addon-link - LinkTo - New TypeScript Errors Apr 9, 2021
@shilman shilman added this to the 6.2 stabilization milestone Apr 10, 2021
@shilman shilman assigned ndelangen and unassigned ndelangen Apr 15, 2021
@shilman shilman added the small label Apr 16, 2021
@ndelangen
Copy link
Member

ndelangen commented Apr 22, 2021

Does anything change if you were to import { LinkTo }?

We specify the types here:

export * from './dist/ts3.9/react';
export { default as LinkTo } from './dist/ts3.9/react';

I'm not sure what we're doing wrong?

I think the types were any before, can you confirm?

If the types were there before, I have no trouble simply removing the react.d.ts file. If that solves this.

@JasonBusse
Copy link

Same issue here. I can get it to build and work using, import LinkTo from '@storybook/addon-links/dist/esm/react'; but eslint is not happy.

Previously, we had imported from @storybook/addon-links/dist/react

When changing to named import import LinkTo from '@storybook/addon-links/react'; we get:
react-dom.development.js:23965 Uncaught (in promise) Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.

@RowanDZ
Copy link

RowanDZ commented Jun 18, 2021

LinkTo is in the package code and general typings exported as default,
but in the type definitions for ts3.9 exported as {LinkTo}

image

node_modules/@storybook/addon-links/react.d.ts

I'm using this for now..

image

@cyberixae
Copy link

As a workaround you could import both separately and combine them in a const.

import LTImp, { LinkTo as LTDec } from '@storybook/addon-links/react';

const LinkTo: typeof LTDec = LTImp as any

@shilman
Copy link
Member

shilman commented Feb 8, 2022

Egads!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.5.0-alpha.38 containing PR #17434 that references this issue. Upgrade today to the @next NPM tag to try it out!

npx sb upgrade --prerelease

@shilman
Copy link
Member

shilman commented Feb 12, 2022

Good golly!! I just released https://github.com/storybookjs/storybook/releases/tag/v6.4.19 containing PR #17434 that references this issue. Upgrade today to the @latest NPM tag to try it out!

npx sb upgrade

@sneko
Copy link

sneko commented Jan 4, 2023

Happening to me with SB v7 despite the PR. I commented the exclude array in tsconfig.json but nothing to do.

JSX element type 'LinkTo' does not have any construct or call signatures.

Any idea?

@ndelangen
Copy link
Member

@sneko can you supply a reproduction for 7.0?

@DannyJoris
Copy link

@ndelangen I ran into this issue as well. I've created an issue for it here where I created a reproduction: #20580

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants