Jon*_*002 5 typescript tsconfig angular-cli typescript-typings
我有一个错误的node_module(angularfire2),它没有使用另一个node_module(@ firebase)中的新版本更新.
我正在尝试让tsconfig.json帮助我为它设置一个路径别名,以便将其重新路由以解析为在src中编写的调整文件而不是@ firebase的node_modules中的不兼容的输入文件作为临时修复.
我知道我可以降级(@firebase)node_module以使其兼容.然而,这个问题并不是要让它发挥作用.我只是想弄清楚如何能够覆盖node_module坏的打字.
我正在使用Angular的cli项目,希望我不需要弹出webpack来控制它.
我从这篇文章中了解到,我覆盖了@types文件夹中的打字.
但是我仍然无法在node_module本身中使用index.d.ts覆盖打字输入.
例如(来自angularfire2)
import { FirebaseApp as FBApp } from '@firebase/app-types';
Run Code Online (Sandbox Code Playgroud)
我想@firebase/app-types在我的tsconfig.json中创建一个别名,以便angularfire2可以查看src/types-overwrite/@firebase/app-types.
我有以下tsconfig.json但它仍然不会正确执行别名,并仍将解析为不兼容的node_module的输入文件而不是src中的文件.
我的tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types",
"src/types-overwrite"
],
"paths": {
"@firebase/app-types": ["src/types-overwrite/@firebase/app-types"]
},
"lib": [
"es2017",
"dom"
]
},
"include": [
"node_modules/angularfire2",
]
}
Run Code Online (Sandbox Code Playgroud)
如何在Angular-CLI项目的node_module中覆盖index.d.ts键入文件,或者如何让我的tsconfig.json工作?
我添加了一个存储库来展示问题:
我在这篇文章中找到了答案:
添加:
复制包类型代码并在声明文件夹中引用它时,我的tsconfig.json:
tsconfig.ts
{
"compilerOptions": {
"lib": ["es6"],
"module": "commonjs",
"noImplicitReturns": true,
"outDir": "lib",
"sourceMap": true,
"target": "es6",
"baseUrl": ".",
"paths": {
"*": [
"src/*",
"declarations/*",
]
},
},
"compileOnSave": true,
"include": ["src/**/*.ts", "src/**/*.tsx", "declarations/**/*.d.ts"],
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
515 次 |
| 最近记录: |