storybookjs / storybook

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

TS1086: An accessor cannot be declared in an ambient context #9463

Closed cloakedninjas closed 4 years ago

cloakedninjas commented 4 years ago

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 <3.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
rafaelgoncalves2010 commented 4 years ago

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 !!

Thank you <3

yangxingting commented 4 years ago

change version to : "ngx-swiper-wrapper": "~8.0.1"

Can solve this problem

nvolodymyr commented 4 years ago

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

;)

SasikalaGanapathy commented 4 years ago

Im using angular 5 is it possible to use ngx-file-upload errr

Yahiani-dev commented 3 years ago

ng update @angular-devkit/build-angular