It enables strict type check for JavaScripts on any TypeScript-based IDE (e.g. VSCode) so that inappropriate function call can be prohibited before running tests.
Adding //@ts-check at the top of the file is all that needed.
I'm all for this!
As an added bonus... if we do manage to get full TS conformance, we might eventually be able to compile some modules as WASM (馃).
we might eventually be able to compile some modules as WASM (馃).
TIL AssemblyScript exists 馃槷
@saschanaz I am taking this up if that's fine. Oh and Happy New Year!! :smiley:
@saschanaz, this can be closed, right?
We still have files without @ts-check, so no. The ultimate goal is to add checkJs: true in jsconfig.json which will enable ts-check in every JS file.
Oh, ok. Thanks for confirming.
https://github.com/w3c/webidl2.js/issues/255 is currently a blocker.
I need to play less computer games and spend some time learning ts. #lifegoals.
Can I do this?
@rahulpurohit29 If you have some TypeScript and JSDoc experience, sure.
If I just add "checkJs":true to the src/jsconfig.json it will globally type check for all .js files, right?
All src/**/*.js files, yes. You will then have to solve the type errors TS shows.
That might be a good place to start - but @saschanaz will know more. Try it and see what errors are emitted. For where the type checks fail, then I assume you would need to go and fix those errors.
I've found too hard to do fix everything at once, so if you get too much errors then just solve some of them and open a PR. Then we can make things better progressively.
Breaking up the problem is a good suggestion... @rahulpurohit29, try to do one file at a time. Any fixes you can make will be a significant contribution to the project. It will also make it easier for us to review the changes you make (and a good opportunity for you to understand the code).
If no one is working on this, I would like to take it up.
@isunitha98selvan Good, feel free to ask questions when needed.
@saschanaz I added "checkJS":true to jsconfig.json. I then tried to test it by running: tsc -p jsconfig.json. I got a bunch of TS5055 errors i.e JS file would overwrite input file. I am kind of stuck here. How should I proceed?
@isunitha98selvan That's weird, would you try npm run lint instead?
@saschanaz ended up with almost 795 errors! Not sure where to start debugging
You can ignore errors from third-party libraries for now.
Most helpful comment
I need to play less computer games and spend some time learning ts. #lifegoals.