Djo*_*lic 4 javascript node.js typescript eslint typescript-eslint
我有一个名为“__ 测试 __”的文件夹。
我希望它被验证为打字稿,但我不想构建该文件夹。(我不希望它进入dist文件夹)
我该怎么做?
好像我必须包括它,但不是真的......
我的 ts.config.json:
{
"compilerOptions": {
"module": "CommonJS",
"target": "ES2017",
"noImplicitAny": true,
"preserveConstEnums": true,
"outDir": "./dist",
"sourceMap": true,
"esModuleInterop": true,
"resolveJsonModule": true
},
"include": ["src/**/*", "src/**/*.json", "__tests__/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"]
}
Run Code Online (Sandbox Code Playgroud)
您可以简单地noEmit在您的用例中使用该选项来不发出输出。
{
"compilerOptions": {
// ...
"noEmit": true,
}
}
Run Code Online (Sandbox Code Playgroud)
我认为您还可以为测试文件创建新的配置,以便include仅从当前的测试代码扩展。
tsconfig.test.json
{
"extends": "./tsconfig.json",
{
"compilerOptions": {
"noEmit": true,
},
"include": [
"__tests__", // your test file
],
}
}
Run Code Online (Sandbox Code Playgroud)
package.json
{
"scripts": {
"build": "tsc",
"test:typeCheck": "tsc --project tsconfig.test.json"
}
}
Run Code Online (Sandbox Code Playgroud)
npm run test:typeChecknpm build| 归档时间: |
|
| 查看次数: |
507 次 |
| 最近记录: |