-
Notifications
You must be signed in to change notification settings - Fork 2.6k
♻️ Refactor: Avoid type system duplication #4596
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: Avoid type system duplication #4596
Conversation
hassoncs
left a comment
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.
If we can do this and still get the same level of compile-time typing, I feel like there's no downside?
|
Yes, this should have the same can't-miss-anything compile-time typing safety guarrantees. Apart from the ordering, it's I think equivalent. |
|
@EamonNerbonne do you have discord? |
|
yeah; I replied in discord for convenience. |
|
@EamonNerbonne I am sorry I am not sure which person you are. Can you DM me (hrudolph)? |
Description
Reduce duplication between compile-time types and run-time types. The aim is to reduce the amount of busywork when changing in particular settings state, without loss of compile-time type safety. This originates from Kilo-Org/kilocode#710 (where I work), but I hope it'll be useful for you too?
Pre-Submission Checklist
I think an example speaks more clearly than type-system mumbo jumbo, so I decided to propose this with this example. If that's really unwanted - no hard feelings for closing the PR.
npm run lint).console.log) has been removed.npm test).mainbranch.npm run changesetif this PR includes user-facing changes or dependency updates.Screenshots / Videos
main:

this branch:

main:

this branch:

One impact to be aware of is that the ordering of the string arrays now follows those of the
zodtypes, and is thus no longer manual. I don't believe that's relevant, but perhaps I'm missing some subtlety.Important
Refactor to reduce type duplication by using
zodschema key extraction inglobal-settings.tsandprovider-settings.ts.keysOffunction fromtype-fu.ts.zodschema key extraction inglobal-settings.tsandprovider-settings.ts.GLOBAL_SETTINGS_KEYSandPROVIDER_SETTINGS_KEYSnow usezodschema key extraction.SECRET_STATE_KEYSis now a constant array with type assertion.zodtypes, not manual.This description was created by
for ba44e63. You can customize this summary. It will automatically update as commits are pushed.