-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
generate types with dts-buddy #658
Conversation
…ns, added .js ext to imports
…les for invalid syntax that isn't downleveled anymore
"import": "./src/index.js" | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"scripts": { | ||
"dev": "pnpm typecheck --watch", | ||
"build": "pnpm typecheck", | ||
"typecheck": "tsc --noEmit --allowJs --checkJs" | ||
"typecheck": "node scripts/generate-dts.js" |
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.
the script would have to be called something like build:types or generate:types to make it more clear that it has output. check suggests it doesn't change.
When exactly would this have to be called during release, how do you ensure that it's output in /types stays in sync with changes to types in /src
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.
elsewhere i'm using prepublishOnly
for this
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.
that does not ensure it stays in sync. You would have to call it in prepare
(similar to how svelte called build in prepare). and even that isn't enough because types can still change and you end up with revisions where they are out of sync.
This basically duplicates src/public.d.ts into types/index.d.ts with the addition of a sourcemap. Is there a way to get the same result without the sourcemap and all these moving parts? v-p-s types are tiny, if all it takes is changing src/index.d.ts to declare the module in place instead of using declare function i'm fine with that. |
Co-authored-by: Dominik G. <[email protected]>
Unfortunately not, unless you want to create a sourcemap by hand. Though I think re-exporting from It does add moving parts and the benefit is more modest in this case since there's really just one giant |
changed to draft for now until we figure out how to integrate it properly |
closing in favor of #751 |
.d.ts
filetypes/index.d.ts
file is generated with an accompanyingtypes/index.d.ts.map
, meaning cmd-click takes you to the implementationUnfortunately couldn't use the CLI for this because the entry point is a
.d.ts
file rather than a.js
file, so this happens via a newscripts/generate-dts.js
module