TypeScript: Duplicate identifier 'IteratorResult'

后端 未结 10 1834
无人共我
无人共我 2020-12-15 01:59

I\'m trying to compile via tsc--which I\'ve installed globally--and I\'m getting an error:

~/AppData/R         


        
10条回答
  •  失恋的感觉
    2020-12-15 02:40

    I suspect it is because your include section:

    "include": [
        "app/**/*.ts",
        "app/**/*.tsx",
        "test/**/*.ts",
        "test/**/*.tsx",
        "node_modules/@types/**/*.d.ts",
        "./types/**/*.d.ts"
      ]
    

    You usually don't need to explicitly include *.d.ts files. And probably never declaration files from other libraries (or node types).

    tsconfig's "exclude" section excludes everything under "node_modules" by default (among other things). When you add "node_modules/@types/**/*.d.ts" you override that exclude and tsc tries to include them, but those types are already declared.

    Check Typescript docs on tsconfig.json, it explains the "typeRoots", "files" and "include"/"exclude" config options in detail.

提交回复
热议问题