typescript – 如何在Angular-CLI项目中覆盖node_module错误输入
我有一个错误的node_module(angularfire2),它没有使用另一个node_module(@ firebase)中的新版本更新.
我正在尝试让tsconfig.json帮助我为它设置一个路径别名,以便将其重新路由以解析为在src中编写的调整文件而不是@ firebase的node_modules中的不兼容的输入文件作为临时修复. 我知道我可以降级(@firebase)node_module以使其兼容.然而,这个问题并不是要让它发挥作用.我只是想弄清楚如何能够覆盖node_module坏的打字. 我正在使用Angular的cli项目,希望我不需要弹出webpack来控制它. 我从post中了解到,我覆盖了@types文件夹中的打字. 但是我仍然无法在node_module本身中使用index.d.ts覆盖打字输入. 例如. (来自angularfire2) import { FirebaseApp as FBApp } from '@firebase/app-types'; 我想在我的tsconfig.json中为@ firebase / app-types创建一个别名,以便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",] } 如何在Angular-CLI项目的node_module中覆盖index.d.ts键入文件,或者如何让我的tsconfig.json工作? 更新: 我添加了一个存储库来展示问题: >’@ firebase / app-types’有额外的日志记录用于记录目的(from_node_modules或from_src)(因此node_modules已经包含在存储库中) 网址:https://github.com/Jonathan002/resolve-typing 解决方法
我在这篇文章中找到了答案:
Exclude/overwrite npm-provided typings 添加: > baseUrl – 路径解析工作所需 复制包类型代码并在声明文件夹中引用它时,我的tsconfig.json: > declarations / package-name.d.ts tsconfig.ts { "compilerOptions": { "lib": ["es6"],"module": "commonjs","noImplicitReturns": true,"outDir": "lib","target": "es6","baseUrl": ".","paths": { "*": [ "src/*","declarations/*",] },},"compileOnSave": true,"include": ["src/**/*.ts","src/**/*.tsx","declarations/**/*.d.ts"],} (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |