TS1086: An accessor cannot be declared in ambient context

前端 未结 12 1538
自闭症患者
自闭症患者 2021-02-01 12:16

I have a thousands of this error after initial implementation nad typing in terminal ng serve my-app of and i can\'t resolve it. This is first time for me when i have problem li

相关标签:
12条回答
  • 2021-02-01 12:29

    Quick solution: Update package.json

    "devDependencies": {
       ...
       "typescript": "~3.7.4",
     }
    

    In tsconfig.json

    {
        ...,
        "angularCompilerOptions": {
           ...,
           "disableTypeScriptVersionCheck": true
        }
    }
    

    then remove node_modules folder and reinstall with

    npm install

    For more visit here

    0 讨论(0)
  • 2021-02-01 12:33

    I had this error when i deleted several components while the server was on(after running the ng serve command). Although i deleted the references from the routes component and module, it didnt solve the problem. Then i followed these steps:

    1. Ended the server
    2. Restored those files
    3. Ran the ng serve command (at this point it solved the error)
    4. Ended the server
    5. Deleted the components which previously led to the error
    6. Ran the ng serve command (At this point no error as well).
    0 讨论(0)
  • 2021-02-01 12:34

    I've updated typescript and tslint versions and removed packages I wasn't using. This solved the problem for me.

    As others pointed here, it seems to be an issue with different TypeScript versions where the generated typings from some library aren't compatible with your TypeScript version.

    0 讨论(0)
  • 2021-02-01 12:37

    try

    ng update @angular/core @angular/cli
    

    Then, just to sync material, run:

    ng update @angular/material
    
    0 讨论(0)
  • 2021-02-01 12:38

    I was working on a fresh project and got the similar type of problem. I just ran ng update --all and my problem was solved.

    0 讨论(0)
  • 2021-02-01 12:40

    I had this same issue, and these 2 commands saved my life. My underlying problem is that I am always messing up with global install and local install. Maybe you are facing a similar issue, and hopefully running these commands will solve your problem too.

    ng update --next @angular/cli --force
    npm install typescript@latest
    
    0 讨论(0)
提交回复
热议问题