question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TS1086: An accessor cannot be declared in an ambient context

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:22
  • Comments:55 (22 by maintainers)

github_iconTop GitHub Comments

57reactions
pankajdaffodilcommented, Mar 16, 2020

Try "skipLibCheck": true, inside tsconfig.json eg.

"compilerOptions": {
    "baseUrl": "src",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "module": "esnext",
    "moduleResolution": "node",
    "importHelpers": true,
    "target": "es2015",
    **"skipLibCheck": true,**
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  },

Hope it will help you !!

45reactions
Snargolcommented, Feb 7, 2020

ng update --next @angular/cli --force npm install typescript@latest

😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

TS1086: An accessor cannot be declared in ambient context
- error TS1086: An accessor cannot be declared in an ambient context. [...] Does somebody know a reason? I can't test my app...
Read more >
Angular 7 (An accessor cannot be declared in an ambient ...
node_modules/@builder.io/sdk/dist/src/builder.class.d.ts(301,16): error TS1086: An accessor cannot be declared in an ambient context.
Read more >
Fixing accessor cannot be declared in an ambient context error
ERROR in node_modules/@angular/animations/browser/browser.d.ts:135:9 - error TS1086: An accessor cannot be declared in an ambient context.h.
Read more >
An accessor cannot be declared in an ambient context. after ...
Hi there, i am trying to upgrade the babylon version to try the new stuff. However after update i am flooded with errors...
Read more >
An accessor cannot be declared in an ambient context
Hi, I'm creating an app with language selection and when I try to run it it gives me the following error. Can someone...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found