storybook: TS1086: An accessor cannot be declared in an ambient context
Describe the bug Upgraded to 5.3.3 just now and our Angular build is failing with the following:
[ng]
[ng] ERROR in ../../node_modules/@storybook/channels/dist/index.d.ts:25:9 - error TS1086: An accessor cannot be declared in an ambient context.
[ng]
[ng] 25 get hasTransport(): boolean;
[ng] ~~~~~~~~~~~~
From a quick google, it appears other repos are facing the same issue due to the use of TypeScript 3.7.0 - but Angular is restricted to ❤️.5.0
Similar errors https://github.com/nestjs/nest/issues/3513 https://github.com/googleapis/node-gtoken/issues/244
I believe the breaking change come from TypeScript directly https://github.com/microsoft/TypeScript/issues/33939 - but until a fix is released, the index.d.ts file will need regenerating with npm i typescript@~3.6.0 (swap ^ for ~)
System:
OS: macOS Mojave 10.14.6
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Binaries:
Node: 12.14.1 - /usr/local/bin/node
npm: 6.13.4 - /usr/local/bin/npm
Browsers:
Chrome: 79.0.3945.117
Safari: 13.0.4
npmPackages:
@storybook/addon-actions: ^5.3.3 => 5.3.3
@storybook/addon-knobs: ^5.3.3 => 5.3.3
@storybook/addon-links: ^5.3.3 => 5.3.3
@storybook/addon-notes: ^5.3.3 => 5.3.3
@storybook/addon-storyshots: ^5.3.3 => 5.3.3
@storybook/addons: ^5.3.3 => 5.3.3
@storybook/angular: ^5.3.3 => 5.3.3
@storybook/cli: ^5.3.3 => 5.3.3
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 22
- Comments: 55 (22 by maintainers)
Commits related to this issue
- Compilation problem solved #6 Angular updated like is suggested in https://github.com/storybookjs/storybook/issues/9463#issuecomment-580609704 — committed to AyundandoAyudar/front by djsanabriac 4 years ago
- fix: Attempt to fix https://github.com/storybookjs/storybook/issues/9463 — committed to maxandriani/ngx-google-analytics by maxandriani 4 years ago
Try "skipLibCheck": true, inside tsconfig.json eg.
Hope it will help you !!
ng update --next @angular/cli --force npm install typescript@latest
😉
If you’re running older version of Angular, e.g. 8.1.0 you’ll see the following error
The Angular Compiler requires TypeScript >=3.4.0 and <3.5.0 but 3.x.y was found instead.I had the same issue. I resolve it by update the Typescript package to the latest version
Son of a gun!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.14 containing PR #9847 that references this issue. Upgrade today to try it out!
Closing this issue. Please re-open if you think there’s still more to do.
Updating with
ng update --next @angular/cli --forceto9.0.0-rc.12which usestypescript @ "3.7.5", has helped the issue indeed.Works!!! Thanks
@gaetanmaisse I’m playing around with a branch to utilize downlevel-dts. At first I dismissed it because it’s not a maintained part of TypeScript but after thinking through it a bit, it could be a viable option to let us use TS3.7+ and still be compatible with <=TS3.5 users. Give me a bit to verify the changes and then we can see if it’s worth the maintenance. The build scripts are pretty tidy so this shouldn’t be too difficult.
Getting this same issue with
typescript 3.7.5andstorybook/react 5.3.9I had a stab at doing the upgrade but got lost in the package structure 😅 - The end result (after dist files are generated) should make
@storybook/channels/dist/index.d.ts:25goFrom
To
Chiming in -
skipLibCheck: trueworks a charm. This is great for those who can’t risk anng updatemid-QA cycle. Thanks!@gaetanmaisse PR is up, let me know if you have any questions.
Thanks for the opportunity to contribute!
Upgrading to TypeScript 3.7.x isn’t a great option for library maintainers. This means that the change from 3.6 to 3.7 (technically a breaking change) gets passed down to our consumers and we can’t assume they can readily upgrade TypeScript either.
@ndelangen I think this can be rectified by changing https://github.com/storybookjs/storybook/blob/next/package.json#L218 to
typescript@~3.6.0, sincetypescript@^3.4.0resolves to3.7.5right now. Then we can save the 3.7 upgrade until until Storybook 6.0 since it’s actually a breaking change.What do you think?
@IsharaMadawa why? Just try to update your typescript version and check if it is working
@siropo What version? i’m using angular 8.3.20 and typescript 3.5.3. And i got same error when try to build the project.
Adding “skipLibCheck”: true, in the compilerOptions inside file tsconfig.json worked for me. Thank you so much .
Ok but how to resolve this issue without typescript update?
works for me @lychyi. thanks so much for taking care of this & thinking it through!!! 💯
re: 3.7 in storybook 6.0. i’m not sure about whether 3.7 is necessary, will let one of the typescript guys speak to that @ndelangen @kroeder @gaetanmaisse
@ColCh It will! We are testing that everything is OK on the latest 6.0.0-alpha and then we will release it in a 5.3.x version 😉
@lychyi Great summary. Uninformed gut feel says definitely 3.7 for 6.0. Seize the future!! 😈
Sounds like a plan @lychyi
Want to open a PR against the
nextbranch?We’ll cherry-pick it into
masterand release as a patch @shilman