代码之家  ›  专栏  ›  技术社区  ›  Teoman shipahi

typescript(tsc)未提取我的.ts文件

  •  0
  • Teoman shipahi  · 技术社区  · 8 年前

    TSC—版本2.8.3

    在我的firebase项目中,从根本上来说 tsconfig.json 如下所示;

    {
      "compilerOptions": {
        /* Basic Options */
        "target": "es5",
        "module": "commonjs",
        "outDir": "./",
        "types": ["mocha"],
        "sourceMap": true,
        "project": "/**/*.ts",
        "watch": true,
        "strict": true
      },
      "exclude": ["node_modules", "typings/browser.d.ts", "typings/browser"]
    }
    

    在下面的文件夹里 test.ts 文件如下;

    app-firebase\functions\Repositories\test.ts
    

    代码:

    abstract class AnimalAbstract {     
      abstract makeSound(): void;
      move(): void {
        console.log("roaming the earth...");
      }
    }
    

    如果我跑 tsc 在根文件夹中,它不会将文件编译到 .js . 但是如果我导航到文件夹并运行 tsc test.ts 它编译。

    我也试着移除 project 参数输入 config 文件,但没有起作用。

    我怎么能做到 watch 整个项目文件夹?

    1 回复  |  直到 8 年前
        1
  •  0
  •   Teoman shipahi    8 年前

    好的,我不得不补充 rootDir 在配置中。

    {
      "compilerOptions": {
        /* Basic Options */
        "target": "es5",
        "module": "commonjs",
        "outDir": "./",
        "types": ["mocha"],
        "sourceMap": true,
        "rootDir": "./",
        "watch": true,
        "strict": true
      },
      "exclude": ["node_modules", "typings/browser.d.ts", "typings/browser"]
    }
    
    推荐文章