@angular-builders/custom-webpack:karma fails compiling TypeScript with activated strictNullChecks
See original GitHub issueDescribe the Bug
When a custom webpack config is provided written in TypeScript, @angular-builders/custom-webpack:karma throws an error if strictNullChecks are activated.
Minimal Reproduction
https://github.com/Markus-Ende/custom-webpack-builder-strictnullchecks-issue
- Clone & install repo
- run
npm test
.
(Deactive strictNullChecks in tsconfig.json to see, that the Error does only occur when activated)
Expected Behavior
Karma tests should run normally.
Error output
An unhandled exception occurred: ⨯ Unable to compile TypeScript:
webpack-config/extra-webpack.config.ts:2:54 - error TS2345: Argument of type 'undefined' is not assignable to parameter of type 'Function'.
2 export default (config) => __awaiter(void 0, void 0, void 0, function* () {
~~~~~~
See "/tmp/ng-Hi3EUl/angular-errors.log" for further details.
Environment
Libs
- @angular/core version: 9.1.9
- @angular-devkit/build-angular version: 0.901.7
- @angular-builders/custom-webpack version: 9.1.0
For Tooling issues:
- Node version: v12.16.1
- Platform: Linux
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
strictNullChecks - TSConfig Option - TypeScript
When strictNullChecks is true , null and undefined have their own distinct types and you'll get a type error if you try to...
Read more >Typescript strictNullChecks with limited scope - Stack Overflow
Is there a way to declare a directory / file / module / class as abiding by strictNullChecks, even when the overall project...
Read more >StrictNullChecks in TypeScript - Best Practice - tsmean
The 'strictNullChecks' TypeScript compiler option allow you to catch null pointers at compile time, providing you with extra safety for your application.
Read more >Angular & TypeScript: Writing Safer Code with strictNullChecks
TypeScript with strict null checking enabled feels even more comfortable for ... of the TypeScript compiler with strictNullChecks turned on: ...
Read more >Writing safer code with TypeScript strict null checks & type ...
It can be enabled by adding the –strictNullChecks flag as an ... Let's have a look at an example that will fail during...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The issue is that there are two instances of
ts-node
registered during the run. No out of the box solution at the moment. As a first step I’d try to remove your directts-node
dependency and if that doesn’t help I’d just usePromise.then
syntax.Ok. A few findings:
async
keyword - once it is removed the problem goes away. So as a workaround you can just use plainPromise
syntax.transpileOnly
option intoregister
. Not sure it’s the right decision though (it is basically your only indication for type errors in your config).tsconfig.json
(built in the builder) for config transpilation. Not sure this is the right decision either, since I do want people to have control of it.#2
or#3
if it was happening with all the commands. But it only happens with Karma and I don’t have any idea why. So I think it’s important to understand how Karma flow is different from the others before we take any actions.