Add type checking to source files
Expected Behavior / Situation
Not having bugs due to type errors
Actual Behavior / Situation
We have bugs such as #375 and #355 that wouldn't be there with static type checking
Modification Proposal
Build the source code with typescript
@matthieu-foucault my recommendation doesn't rewrite code on typescript because it is hard maintenance for other developers, who not familiar with typescript and there are a lot of such contributors.
In webpack we use Typescript comments like this https://github.com/webpack/webpack/blob/master/lib/Compiler.js#L37. It is allow to static type checking and other developers easy work with code (you can merge PRs and late add types).
Nice!, I didn't know that was possible, thanks for the tip!
For future reference, here's the documentation for that: https://www.typescriptlang.org/docs/handbook/type-checking-javascript-files.html
So the idea is to keep js as is (just add some typescript definition files + jsdocs) but still run a check via typescript?
that actually sounds really nice :)
@daKmoR yep, you can look setup in webpack repo :+1:
@evilebottnawi at this wip you can see my intial attempt at starting type linting - can you pls check if it's the right direction?
also would we still need to generate type definition files or are the js doc hints good enough? If there would be a need to generate them any sugguestion on howto? I looked at the webpack setup but that seems rather complex 🙈
Generating the typedefs is done simply by adding "declaration": true to the tsconfig compilerOptions,
and adding a "types": "./lib/main.d.ts" entry to the package.json.
The other option is to publish under @types/karma-webpack, which may be the preferred way (at least that seems to be what webpack is doing).
Either way, I don't think that publishing the type declarations would have much of an impact (unless someone writes something that extends karma-webpack :fearful: )
Generating the typedefs is done simply by adding "declaration": true to the tsconfig compilerOptions, and adding a "types": "./lib/main.d.ts" entry to the package.json.
@matthieu-foucault hmm that does not seem to work? I would expect that a file ./lib/main.d.ts get's generated if I run ./node_modules/.bin/tsc --declaration
Sorry, just noticed that comment now: might be because of the noEmit option?
As karma is now deprecated and coming up on EOL, we are no longer planning on any significant enhancements to this project and are instead going to focus on security updates, stability, and a migration path forward as karma's lifecycle comes to an end.
Thank you for supporting and using this project!