Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use @ts-check wherever appropriate #1905

Closed
saschanaz opened this issue Nov 23, 2018 · 23 comments · Fixed by #2543
Closed

Use @ts-check wherever appropriate #1905

saschanaz opened this issue Nov 23, 2018 · 23 comments · Fixed by #2543
Labels
good first issue These bug should be easy for anyone getting started

Comments

@saschanaz
Copy link
Collaborator

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.

@saschanaz
Copy link
Collaborator Author

Adding //@ts-check at the top of the file is all that needed.

@marcoscaceres
Copy link
Contributor

I'm all for this!

@marcoscaceres
Copy link
Contributor

As an added bonus... if we do manage to get full TS conformance, we might eventually be able to compile some modules as WASM (🤞).

@saschanaz
Copy link
Collaborator Author

we might eventually be able to compile some modules as WASM (🤞).

TIL AssemblyScript exists 😮

@devanshbatra04
Copy link
Contributor

@saschanaz I am taking this up if that's fine. Oh and Happy New Year!! 😃

@marcoscaceres
Copy link
Contributor

@saschanaz, this can be closed, right?

@saschanaz
Copy link
Collaborator Author

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.

@marcoscaceres
Copy link
Contributor

Oh, ok. Thanks for confirming.

@marcoscaceres marcoscaceres added the good first issue These bug should be easy for anyone getting started label Jan 10, 2019
@saschanaz
Copy link
Collaborator Author

w3c/webidl2.js#255 is currently a blocker.

@marcoscaceres
Copy link
Contributor

I need to play less computer games and spend some time learning ts. #lifegoals.

@rahulpurohit29
Copy link

Can I do this?

@saschanaz
Copy link
Collaborator Author

@rahulpurohit29 If you have some TypeScript and JSDoc experience, sure.

@rahulpurohit29
Copy link

If I just add "checkJs":true to the src/jsconfig.json it will globally type check for all .js files, right?

@saschanaz
Copy link
Collaborator Author

All src/**/*.js files, yes. You will then have to solve the type errors TS shows.

@marcoscaceres
Copy link
Contributor

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.

@saschanaz
Copy link
Collaborator Author

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.

@marcoscaceres
Copy link
Contributor

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).

@isunitha98selvan
Copy link
Contributor

If no one is working on this, I would like to take it up.

@saschanaz
Copy link
Collaborator Author

saschanaz commented Mar 1, 2019

@isunitha98selvan Good, feel free to ask questions when needed.

@isunitha98selvan
Copy link
Contributor

@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?

@saschanaz
Copy link
Collaborator Author

@isunitha98selvan That's weird, would you try npm run lint instead?

@isunitha98selvan
Copy link
Contributor

@saschanaz ended up with almost 795 errors! Not sure where to start debugging

@saschanaz
Copy link
Collaborator Author

You can ignore errors from third-party libraries for now.

saschanaz pushed a commit that referenced this issue Oct 19, 2019
* chore: use @ts-check in all src files

Fixes #1905

* Fix param name in src/type-helper.d.ts

Co-Authored-By: Sid Vishnoi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue These bug should be easy for anyone getting started
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants