typescript - 打字稿编译问题使用“参考”来获取项目中的共享文件
问题描述
我正在尝试编译我的 Typescript 项目,该项目使用项目范围之外的一些共享文件。我试图在输出目录中有一个扁平的结构。它看起来像这样:
- /shared/interfaces/ 下的一些共享文件,包含 test.interface.ts 和 tsconfig.json
- /back-end/project1/ 下的项目 ts 文件列表 + tsconfig.json 文件 在其中一个文件 (test.model.ts) 中,我有一个 'import {Itest} from '../../.. /../shared/interfaces/test.interface'
命令 'tsc --build' 没有错误(/shared/interface 中的部分也已正确编译),但项目输出目录不包含 test.interface.js 文件和 test.model 中的导入路径。 ts 到达 test.interface 也没有改变。所以当我运行项目时,我显然有一个错误。共享文件夹中的 tsconfig.json 如下所示:
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"declarationMap": true,
"target": "es6",
"rootDir": ".",
"composite": true,
}
}
项目 tsconfig.json 看起来像这样:
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"moduleResolution": "node",
"sourceMap": true,
"rootDir":"src",
"outDir": "dist"
},
"lib": ["es2015"],
"references": [
{ "path": "../../shared/interface/" }
]
}
我不知道我做错了什么。谢谢你的帮助。
解决方案
推荐阅读
- python - 将 python elasticsearch 响应转换为表或 csv
- twitter-bootstrap - 使用 Accordion 的 Scrollspy?
- python - 如何将此字符串转换为空格也是单独项目的列表?
- xtext - 在基于 Xtend 的 Xtext 代码生成器中使用 Inject
- cosmicmind - iOS App 在后台运行 - 需要使用 Graph 删除 removeFilePresenter
- javascript - event.preventDefault 无法正常工作
- google-cloud-dataflow - Google Dataflow 上的 Apache Beam IllegalArgumentException 带有消息“不期望可拆分的 ParDoSingle:应该已被覆盖”
- javascript - 创建一个显示/隐藏按钮来切换表格列
- c++ - 如何递归复制文件和目录
- python - OpenAI Gym 无法在控制台环境中正确渲染颜色