TS1086: An accessor cannot be declared in an ambient context

后端 未结 2 879
庸人自扰
庸人自扰 2021-01-22 04:57

When running with Angular, I\'m getting thje error TS1086: An accessor cannot be declared in an ambient context. for Javascript getters and setters in this Abstract

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-22 05:49

    I had this a similar problem with google-auth-library.

    I'm on Ubuntu and call tsc to transpile my nodejs server from typescript to javascript, but running 'tsc' was throwing the 'TS1086: An accessor cannot be declared in an ambient context' error.

    Initially, I tried updating typescript by running npm install typescript@latest from my server directory but was still seeing errors.

    I had to update my global version of typescript so 'tsc' could run, but running npm install typescript@latest -g was also throwing errors. I had to remove the tsc link in /usr/bin/.

    What I did to fix:

    $ cd /usr/bin
    $ sudo rm tsc
    $ sudo npm install -g typescript@latest
    

    Calling 'tsc' worked without errors after this.

提交回复
热议问题