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

Adding JSDoc to ts.d files #199

Open
kberg opened this issue Oct 6, 2022 · 3 comments
Open

Adding JSDoc to ts.d files #199

kberg opened this issue Oct 6, 2022 · 3 comments

Comments

@kberg
Copy link

kberg commented Oct 6, 2022

I'd like to add some jsdoc to the ts.d files to improve the experience using vscode. I am happy to submit a pull request with your permission.

@Yomguithereal
Copy link
Owner

Sure @kberg I will probably merge such PR if it does not replicate all the JSDoc from the javascript files. I am wondering whether there could exist a way to do so automatically by the way (probably not, which is sad, I keep the files in native javascript to avoid any transpilation step that has the nasty habit of befuddling the code sometimes and ruining performance in some scenarios that are required to remain as performant as possible).

@Macil
Copy link
Contributor

Macil commented Dec 5, 2023

When Typescript is targeting modern JS, Typescript compilation basically just strips out the type definitions without adding any compatibility helpers. Typescript only does tricky stuff in compilation when you both use new JS features and set old JS engines as the compilation target. (Well, Typescript also does some minor syntax transforms to make objects out of enums and namespaces though there's no need to use those anyway.)

As a test, I converted static-interval-tree.js to Typescript in the most minimal way (adding : any casts where it wanted type declarations), compiled it to JS, ran an auto-formatter on the original static-interval-tree.js and the newly compiled static-interval-tree.js, compared them with diff set to ignore whitespace changes, and the only difference was that Typescript added "use strict" to the top (and even that's configurable).

(Well it is true though that writing directly in Typescript would provide strong encouragement to use the ES6 class syntax, though I don't think there are performance costs associated with that and the compiled function/method bodies should be able to stay untouched.)

@Yomguithereal
Copy link
Owner

It's not so much TS I am afraid of but rather ES5 transpilation (by Babel typically). I have encountered many ES6->ES5 shims that would alter performance in a significant way (spread operator thingy and class polyfills typically). But keep in mind this was the case some years ago. I am sure it has improved now, but I did not check again lately. In any case, rewriting the whole codebase in modern TS/JS would be quite costly to do and I currently have zero incentive to do so personally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants