You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changes `uuid` to be represented as unknown which causes most `as` casts
to fail since TS safeguards against casting "string" to unknown. Adds a
new type called `OrganizationId` which is manually set to be equal to
`Tagged<Uuid, "OrganizationId">` on the TS side. This prevents mixing up
the type with other Uuid's.
In order to create an OrganizationId in the application you now need to
pass through unknown otherwise you get the following error message:
`Conversion of type 'string' to type 'Tag<"OrganizationId", never>' may
be a mistake because neither type sufficiently overlaps with the other.
If this was intentional, convert the expression to 'unknown' first.`
To provide some ergonomics we should add the following function in
typescript:
```
export function uuid<T extends Uuid>(uuid: string): T {
if (Utils.isGuid(uuid)) {
return uuid as T;
}
throw new Error(`Invalid UUID: ${uuid}`);
}
```
0 commit comments