-
Notifications
You must be signed in to change notification settings - Fork 19
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: move types into types.ts #47
Conversation
473229a
to
4d689c0
Compare
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.
Looks pretty good to me, but the build command seems to leave an 'empty' types.js file (both on the esm and cjs builds), which shouldn't cause any problems but probably isn't intended. After looking for a while it seems it is the way tsc works. Also, if types are being explicitly declared in the types.ts file, shouldn't it be named types.d.ts or something similar?
The compilation will still output it as a declaration file. I don't want a manual declaration file to be maintained, the ts file will still have type checking on it where a hard coded declaration wouldn't. The point of moving them is just to separate the code a bit - make it easier to maintain / review and move the type only things out of the implementation.
The second one here being the most important, it's a side effect of Lots of people complaining that type only exports / imports end up with this side effect. Using For now I just added some manual removals of the empty types.js |
This PR should not have any API impact, it is purely a typescript refactor which maintains existing build output and behaviour.
index.ts
totypes.ts
tsup
as a dev dependency forbuild:types
script - this allows a single type declaration file to be output from multiple typescript filesindex.d.ts
andindex.d.cts
files - it's no longer a direct copyI compared the new type declaration output to the old / previous and it appears to me to be the same - if someone else could confirm / verify that would be nice!
Since we have a breaking change to fix a current bug / missing feature, I also plan on renaming some of the types to be less generic to avoid potential type name clashing in the global scope (alternatively, wrap declared types in a "csrf-csrf" module block).