Using act
为了通过 Docker 在本地测试 github-actions,我在 github-action 工作流程中遇到了各种 TS 错误(TS2345、TS18046、TS2339 等...)。这些错误是not在本地开发和运行期间观察到tsc -p tsconfig.build.json
在我的本地计算机上结果编译成功。
github-action 运行于ubuntu-latest
我已经确认运行程序已配置为使用与本地版本相同的节点、npm、yarn 和 tsc 版本。
- Node -
v18.13.0
- npm -
v8.19.3
- yarn -
1.22.19
- tsc -
v4.9.4
此外,我已经确认 TSC 在 github-action 期间使用的配置与我的本地配置相同(来自tsc --showConfig
,比较本地和 github-action 的差异)。使用 github-action 中的相同 docker 容器,我可以访问终端并运行相同的命令,而不会看到错误。
鉴于节点、npm、yarn 和 tsc 版本在我的本地和 github-action 中是相同的,什么可能导致这种不同的行为?
tsconfig.json
{
"compilerOptions": {
"rootDir": "./src",
"module": "commonjs",
"declaration": false,
"noImplicitAny": false,
"skipLibCheck": true,
"removeComments": true,
"noLib": false,
"allowSyntheticDefaultImports": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"esModuleInterop": true,
"target": "ES2021",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "src",
"incremental": true,
"strictNullChecks": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "**/*.spec.ts"],
"paths": {
"@module": ["src/module"]
}
}