-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add functions package #1171
base: main
Are you sure you want to change the base?
Add functions package #1171
Conversation
* limitations under the License. | ||
*/ | ||
|
||
export type Integer<T extends number = number> = T & { __integerBrand: void }; |
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 these numeric types have the same brand? Otherwise you wouldn't be able to assign them to one another very easily.
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.
Hm yeah I'm slightly worried about the users having to do lots of type assertions to get around compiler errors with assignment. My stance is that we should allow users to do whatever they want with numerics within the body and be flexible there, and our runtime should validate the precision of input and output values at runtime.
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.
As discussed: make this an optional brand
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.
Yup, and will also add date types
export type Double<T extends number = number> = T & { __doubleBrand?: void }; | ||
export type Long<T extends string = string> = T & { __longBrand?: void }; | ||
|
||
export type DateISO<T extends string = string> = T & { __dateBrand?: void }; |
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.
I also wouldn't be against calling this DateISOString
for maximum clarity and deprecating the type /supporting it in addition to Temporal.PlainDate
. Likewise with TimestampISOString
below
Add functions package to start exporting functions specific types, right now, just the primitives