Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Add functions package #1171

wants to merge 5 commits into from

Conversation

ssanjay1
Copy link
Contributor

@ssanjay1 ssanjay1 commented Feb 4, 2025

Add functions package to start exporting functions specific types, right now, just the primitives

* limitations under the License.
*/

export type Integer<T extends number = number> = T & { __integerBrand: void };

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.

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.

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

Copy link
Contributor Author

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

@ssanjay1 ssanjay1 marked this pull request as ready for review February 6, 2025 19:08
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 };

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants