【问题标题】:Typescript generates file in incorrect directory打字稿在不正确的目录中生成文件
【发布时间】:2016-08-22 09:19:45
【问题描述】:

这是我的 tsconfig.json 的片段,typescript 编译器使用它来为我的 ts 文件生成 JS 文件。这些文件是从类型目录中挑选出来的,并且生成的源应该是在 "./app/scripts" 目录中创建的。出于某种原因,typescript 编译器会在 "./app/scripts/typings" 目录下生成 js 脚本。如何强制打字稿跳过打字目录?

  "compilerOptions": {
    "target": "es5",
    "module": "amd",
    "moduleResolution": "node",
    "sourceMap": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "removeComments": false,
    "noImplicitAny": false,
    "listFiles": true,
    "diagnostics": true,
    "outDir": "./app/scripts"
  },
  "filesGlob": [
    "./app/typings/**/*.ts",
    "./typings/main.d.ts",
    "./app/test/typings/**/*.ts"
  ], 
 "files": [
   "./app/typings/App.ts",
   "./app/typings/services/AService.ts"
  ] 

我也尝试从命令行传递 --outDir 参数。它在 "./app/scripts/typings"

下创建 js 脚本

【问题讨论】:

  • 将 tsconfig.json 文件移动到您的 app/typings 文件夹中。
  • 您的 tsconfig 文件相对于应用程序的路径是什么?
  • 与app目录同级

标签: typescript tsc


【解决方案1】:

尝试在 tsconfig.json 文件中将 rootDir 选项设置为 ./app/typings。 欲了解更多信息:rootDir

这应该会有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-01
    • 1970-01-01
    • 2019-10-29
    相关资源
    最近更新 更多