Using act to locally test github-actions via Docker, I am getting a variety of TS errors (TS2345, TS18046, TS2339, etc...) during my github-action workflow. These errors are not observed during local development and running tsc -p tsconfig.build.json on my local machine results in a successful compilation.
The github-action runs on ubuntu-latest and I have confirmed that the runner is configured to use the same versions of node, npm, yarn and tsc as my local.
v18.13.0v8.19.31.22.19v4.9.4Furthermore, I have confirmed that the config TSC uses during the github-action is identical to my local config (output from tsc --showConfig, compared diff from local and github-action). Using the same docker container from the github-action, I can access the terminal and run the same commands without seeing the errors.
Given that the node, npm, yarn and tsc versions are the same across my local and github-action, what could possible cause this different behavior?
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"]
}
}
I had a similar issue and it was caused by not having all the packages listed in package.json.
I'm still not sure why it built successfully locally (perhaps I had leftover files in node_modules?) but I traced the error messages to the specific lines and found that it was due to a particular import that was missing. Added it to package.json and the errors went away.
Since your question was asked quite some time ago, I just posted a very similar question here, perhaps this'll help you out as well. Basically, not installing the required packages in your workflow can cause other TS errors. Simply adding uses: npm install before run: tsc -p tsconfig.json did the job for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With