-
Notifications
You must be signed in to change notification settings - Fork 59
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
feat: generate ts types #637
Conversation
Adds a `generate-types` command to generate `*.d.ts` files. Largely inspired by @AuHau's work on achingbrain/uint8arrays#4
Oh yeah, there's also #568 which I forgot existed. Would be good to get something shipped here. |
} | ||
|
||
const forwardOptions = argv['--'] ? argv['--'] : [] | ||
const args = ['-d', '--emitDeclarationOnly'].concat(forwardOptions).concat(files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not we be passing a --declarationDir
as well or is it expected to be passed as part of --
?
Any flags or config to pass to `tsc` can be specified as forward options: | ||
|
||
```console | ||
$ aegir generate-types --overwrite 'src/**/*.js' -- --allowJs --esModuleInterop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please note that tsconfig.json
affects a lot what options can be passed or how they collide. E.g. having noEmit
compiler option will prevent emitDeclarationOnly
passed here.
I don't think documenting every single collision is realistic, but maybe a note or a link to an example setup might be helpful.
@achingbrain I think we need to decide between:
My preference lays towards the 2nd option because:
I can also take over this work so I can align / coordinate it with ipfs/js-ipfs#3281 |
typeVersions is a thing now??? wow nice!!! |
I'm always slightly annoyed by VSCode when I try to click through to source code and it takes me to a type definition nowhere near the actual code that's being executed. The reason I'm looking for source code is because I either don't understand what a function is doing, or I think there's a bug in the function - type defs don't help me with either problem. If the defs are next to the actual implementation it's at least slightly less irritating. Maybe there's a better way here, I don't know. TBH I'm sort of getting used to click through being broken. As for the polluting the source tree thing, my thinking here was to only generate If the source tree pollution is so bad we can always add a I'd rather not have hand-crafted
Eh, no, not really, I'd rather treat it like another linting step, but that's my personal preference.
Please do. I was going to close this PR in favour of #568 as it seems to be a more complete solution but if you think there's value here please do what's necessary. |
100% +1 on @achingbrain comment @Gozala you said you figured out cmd+click to source thing here https://github.com/Gozala/web-blob/pull/7#issuecomment-660722815 |
There is now typedefs maps kind of like source maps that supposedly solve that. In my tests it seemed to work but they are not widely used yet. |
Adds a
generate-types
command to generate*.d.ts
files.Largely inspired by @AuHau's work on achingbrain/uint8arrays#4