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

[typeid-js] Enforce prefix (optionally) #344

Merged
merged 4 commits into from
Jul 2, 2024
Merged

Conversation

mikeland73
Copy link
Contributor

Summary

Brings it inline with unboxed version. Makes type-checking much more reliable (because it now throws an error if prefix is wrong). Because the current implementation uses as T, if the prefix is not specified, the typechecker type has no relationship to the input data.

Arguably this should have been the default. It requires the same amount of typing because the template type doesn't need to be added:

const id = TypeID.fromString(stringId, "foo")
// id is of type TypeID<"foo">

Unfortunately we can't do this without breaking backward compatibility.

How was it tested?

unit tests

@mikeland73 mikeland73 requested review from loreto and LucilleH June 26, 2024 22:33
Copy link
Contributor

@loreto loreto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mikeland73 mikeland73 merged commit a1eed99 into main Jul 2, 2024
2 checks passed
@mikeland73 mikeland73 deleted the landau/enforece-typeidjs branch July 2, 2024 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants