tsconfig - How to ignore @types/whatever/node_modules for a specific directory?

别说谁变了你拦得住时间么 提交于 2019-12-06 03:17:38

问题


I'm running angular 1.5 with typescript (yay), and we include both @types/angular and @types/angular-mocks.

The trouble is that @types/angular-mocks lists @types/angular as a dependency with * versioning. This causes yarn to install 1.6 in @types/angular-mocks/node_modules.

The final result is a ts compile error: @types/angular 1.5 has a different definition for $inject than @types/angular 1.6

How can I get the tsconfig to ignore @types/angular-mocks/node_modules?

Here is my current tsconfig:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "sourceMap": true,
        "noImplicitAny": false,
        "allowSyntheticDefaultImports": true,
        "forceConsistentCasingInFileNames": true,
        "lib": [
            "es2016",
            "dom"
        ],
        "rootDir": "app/modules",
        "mapRoot": "/modules/",
        "sourceRoot": "/modules",
        "typeRoots": ["./node_modules/@types"],
        "baseUrl": ".",
        "paths": {
            "*": [
                "app/modules/*"
            ]
        }
    },

    "include": [
        "./node_modules/@types",
        "./typings-custom/*.d.ts"
    ],

    "exclude": [
        "node_modules"
    ]
}

来源:https://stackoverflow.com/questions/48427807/tsconfig-how-to-ignore-types-whatever-node-modules-for-a-specific-directory

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!