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

@storybook/api raising typescript TS2411 - incorrect use of indexed property #7069

Closed
rosskevin opened this issue Jun 12, 2019 · 4 comments
Closed

Comments

@rosskevin
Copy link

Describe the bug
Incorrect use of indexed properties resulting in TS2411 downstream when included by tsc.

Trying to upgrade to 5.1.3 and my typescript based monorepo fails on definitions produced by @storybook/api, specifically ts(2411):

$ /Users/kross/projects/js/node_modules/.bin/tsc -b
../../node_modules/@storybook/api/dist/modules/versions.d.ts:12:9 - error TS2411: Property 'latest' of type 'Version | undefined' is not assignable to string index type '{ [key: string]: any; }'.

12         latest?: Version;
           ~~~~~~

../../node_modules/@storybook/api/dist/modules/versions.d.ts:13:9 - error TS2411: Property 'next' of type 'Version | undefined' is not assignable to string index type '{ [key: string]: any; }'.

13         next?: Version;
           ~~~~

../../node_modules/@storybook/api/dist/modules/versions.d.ts:14:9 - error TS2411: Property 'current' of type 'Version | undefined' is not assignable to string index type '{ [key: string]: any; }'.

14         current?: Version;
           ~~~~~~~

../../node_modules/@storybook/api/dist/index.d.ts:61:13 - error TS2411: Property 'latest' of type 'Version | undefined' is not assignable to string index type '{ [key: string]: any; }'.

61             latest?: import("./modules/versions").Version;
               ~~~~~~

../../node_modules/@storybook/api/dist/index.d.ts:62:13 - error TS2411: Property 'next' of type 'Version | undefined' is not assignable to string index type '{ [key: string]: any; }'.

62             next?: import("./modules/versions").Version;
               ~~~~

../../node_modules/@storybook/api/dist/index.d.ts:63:13 - error TS2411: Property 'current' of type 'Version | undefined' is not assignable to string index type '{ [key: string]: any; }'.

63             current?: import("./modules/versions").Version;

To Reproduce
Steps to reproduce the behavior:

  1. create a typescript project
  2. yarn add @storybook#addon-actions which will transitively give you @storybook/api
  3. tsc -b

Expected behavior
No typescript errors from published files

Screenshots
versions_d_ts_—_js

Code snippets
n/a

System:

  • OS: osx
  • Framework: react
  • Version: 5.1.3

Additional context
[email protected]

Specifically, Version is not the same type as the indexer.

@gaetanmaisse
Copy link
Member

@rosskevin can you share your tsconfig.json? because I can't reproduce your pb on my company big front monorepo.

@rosskevin
Copy link
Author

@gaetanmaisse here is our base config:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2015",
    "jsx": "react",
    "lib": ["es2017", "esnext.asynciterable", "dom"],

    "allowSyntheticDefaultImports": true,
    "declaration": true,
    "declarationMap": true,
    "esModuleInterop": true,
    "forceConsistentCasingInFileNames": false,
    "moduleResolution": "node",
    "noImplicitAny": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "noEmitOnError": true,
    "noUnusedLocals": false,
    "strict": true,
    "sourceMap": true,
    "suppressImplicitAnyIndexErrors": true
  }
}

@n3utrino
Copy link

n3utrino commented Jul 9, 2019

As a workaround, add

"skipLibCheck": true

to your compilerOptions

@shilman
Copy link
Member

shilman commented Jul 10, 2019

Good golly!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.0-alpha.40 containing PR #7072 that references this issue. Upgrade today to try it out!

You can find this prerelease on the @next NPM tag.

Closing this issue. Please re-open if you think there's still more to do.

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

No branches or pull requests

4 participants