Tag
Type tagging and branding for TypeScript.
yarn add @corets/tagnpm install --save @corets/tagQuick Start
type UUID = string
type User = { id: UUID }const user: User = { id: "some-uuid" }import { Tag } from "@corets/tag"
type UUID = Tag<string, "uuid">
type User = {
id: UUID
}
// this will not work since string is not assignable to UUID
const user1: User = { id: "some-uuid" }
// exlicitly cast it to UUID
const user2: User = { id: "some-uuid" as UUID }Tag<type, alias>
Last updated
Was this helpful?