Skip to content

Shorter Implementation of Nominal #1

@MananTank

Description

@MananTank
const M = Symbol();

export type Nominal<Name extends string, Type> = Type & {
  readonly [M]: [Name];
};

Works with all the examples mentioned in readme.md

check it out :

https://codesandbox.io/s/nominal-types-l8k9ti?file=/src/nominal.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions