代码之家  ›  专栏  ›  技术社区  ›  Vipul Rajan

Turbo Repo即使存在Typescript错误也能构建

  •  0
  • Vipul Rajan  · 技术社区  · 1 年前

    我有一个涡轮回购单回购。结构是这样的:

    apps
    |- app1
    |- app2
    
    packages
    |- lib
       | .... some files
       |- tsconfig.json
       |- package.json
    

    在…内 lib 我故意创建了一个明显错误的文件。编辑时会在编辑器中报告错误:

    const a: String = 23;
    console.log(a);
    

    我也正在我的一个应用程序中导入此文件。当我尝试使用构建项目时 npm run build 它构建时没有任何错误。我没有设置忽略错误的选项。

    只有当我把这个故意产生错误的文件放在其中一个应用程序中时,构建才会失败。它们给出了正确的错误并中止了构建。

    这是的tsconfig lib

    {
      "compilerOptions": {
        "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, // "lib": [],                                        /* Specify a set of bundled library declaration files that describe the target runtime environment. */
        "module": "commonjs" /* Specify what module code is generated. */, // "rootDir": "./",                                  /* Specify the root folder within your source files. */
        "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, // "preserveSymlinks": true,                         /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
        "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */ /* Type Checking */,
        "strict": true /* Enable all strict type-checking options. */, // "noImplicitAny": true,                            /* Enable error reporting for expressions and declarations with an implied 'any' type. */
        "skipLibCheck": true /* Skip type checking all .d.ts files. */,
        "lib": ["dom", "dom.iterable", "esnext"],
        "allowJs": true,
        "noEmit": true,
        "incremental": true,
        "resolveJsonModule": true,
        "isolatedModules": true,
        "jsx": "preserve",
        "moduleResolution": "node"
      },
      "include": ["."],
      "exclude": ["dist", "build", "node_modules"]
    }
    

    我的应用程序中也有一个几乎相同的tsconfig

    {
      "compilerOptions": {
        "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, // "lib": [],                                        /* Specify a set of bundled library declaration files that describe the target runtime environment. */
        "module": "commonjs" /* Specify what module code is generated. */, // "rootDir": "./",                                  /* Specify the root folder within your source files. */
        "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, // "preserveSymlinks": true,                         /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
        "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */ /* Type Checking */,
        "strict": true /* Enable all strict type-checking options. */, // "noImplicitAny": true,                            /* Enable error reporting for expressions and declarations with an implied 'any' type. */
        "skipLibCheck": true /* Skip type checking all .d.ts files. */,
        "lib": ["dom", "dom.iterable", "esnext"],
        "allowJs": true,
        "noEmit": true,
        "incremental": true,
        "resolveJsonModule": true,
        "isolatedModules": true,
        "jsx": "preserve",
        "moduleResolution": "node"
      },
      "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
      "exclude": ["node_modules"]
    }
    
    0 回复  |  直到 1 年前
        1
  •  0
  •   vnva    1 年前

    我也有类似的问题。安装nodejs的稳定版本有帮助