-
Notifications
You must be signed in to change notification settings - Fork 80
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
refactor: use type-checked JS instead of TS for quickstart examples #1215
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1215 +/- ##
=======================================
Coverage 77.81% 77.81%
=======================================
Files 84 84
Lines 17523 17523
Branches 1781 1781
=======================================
Hits 13635 13635
Misses 3853 3853
Partials 35 35 ☔ View full report in Codecov by Sentry. |
I'm ok exploring this, but the main reason why we had this "duplicated" code in the first time was to show people how the example would look in two different languages. Using |
(I initially linked the wrong issue in the PR description, I meant to be referring to #1108, which is now fixed.) |
Hmm, I see, I wasn't aware of that. I think the current JS examples might not be that great in that respect, though, since they contain some polyfills (e.g. for enums) and lines like |
I tried it out locally and it works nice... similar behavior in VS code as with TS files 👍 On the one hand I agree with @relu91 that having samples for both TS and JS is beneficial. Mhhh, not sure what we should do... I wonder what is most used TS or JS ? |
Hmm, yeah, with Node.js, the situation is also not ideal since JavaScript with the CommonJS syntax is not a true subset of TypeScript (for that we would need to use ES Modules, but their compatibility with the older CommonJS approach is somewhat limited). Otherwise, we could cover both languages at the same time :/ However, as every TypeScript developer should be familiar with JavaScript, I would personally say that using only JS examples should cover the largest amount of people while making the examples themselves more accessible. |
I think I like this approach, some thoughts:
|
Does it make sense to put this topic on the agenda of one of our next weekly calls? EDIT: Maybe an according label would be also good so that we can easily find topics/issues for the calls... |
I now created a label called "Discuss in Committer Meeting" for that :) |
Some discussions from the meeting today:
|
Working with ES2021 does not seem to generate that ugly JS anymore, what do you think? |
That is great! Once we move on with #1340 we can also remove the workflow described here node-wot/packages/examples/README.md Lines 14 to 29 in 5afa858
|
This PR contains an initial proposal for a partial implementation of #1108, removing the (sort of redundant) TS files for the quickstart examples and instead adding type checking via a
@ts-check
comment to the respective JS example files. Additional type information is added via JSDoc comments.This PR can serve as a basis for discussing if this is the direction we want to go with the other examples as well – if so, then I would open PRs for the other examples (or rather: those that should remain in the node-wot repository) as well.