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

Future: Possibly more automated type compilation #3157

Open
joshgoebel opened this issue Apr 21, 2021 · 1 comment
Open

Future: Possibly more automated type compilation #3157

joshgoebel opened this issue Apr 21, 2021 · 1 comment
Labels
good first issue Should be easier for first time contributors help welcome Could use help from community package/build Issues relating to npm or packaging parser

Comments

@joshgoebel
Copy link
Member

Getting access to the types in my main source. My source is all JS, it exports no types... all the type exports are ambient modules.

I’m proposing the inverse: define your types in your code.

I dunno what that means? You mean declare them in highlight.js itself and then export them, import them into index.d.ts and then reexport them? I'm not sure I know how to do that if that's possible - or advisable?

Indeed: write them in JavaScript. No need to add a manual index.d.ts: typescript can compile javascript and generate that index.d.ts.

Here’s a smaller example: words/levenshtein-edit-distance@2c3d890.
Lowlight is a bit more involved.
A bit more complex is unist-util-select: syntax-tree/unist-util-select@4c1b02e.
And quite complex is xdm: https://github.com/wooorm/xdm.

I am not a fan of typescript. I personally don’t really love types either. But they are somewhat useful — especially for newcomers to a giant ecosystem (unified).
I think types through jsdoc in javascript is rather nice: code is directly runnable, no building needed. But everything is still type checked by typescript (and I like type-coverage to ensure everything is completely typed).
It ensures .d.ts are kept up to date and work

Some more info here: https://github.com/voxpelli/types-in-js

Originally posted by @wooorm in #3131 (comment)

@joshgoebel
Copy link
Member Author

If someone knows how this is done and would like to whip up a tiny PR, I'd love to see it. I think what would be since is a tiny utility script that we could run periodically that would compile the types. I also wonder if this magically will create ambient modules as we do now.

@joshgoebel joshgoebel added good first issue Should be easier for first time contributors help welcome Could use help from community package/build Issues relating to npm or packaging parser labels Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Should be easier for first time contributors help welcome Could use help from community package/build Issues relating to npm or packaging parser
Projects
None yet
Development

No branches or pull requests

1 participant