Skip to content

Instantly share code, notes, and snippets.

@ehatricksmith
Created May 31, 2022 05:32
Show Gist options
  • Save ehatricksmith/43a1131c4025848f2cd1802a6449a723 to your computer and use it in GitHub Desktop.
Save ehatricksmith/43a1131c4025848f2cd1802a6449a723 to your computer and use it in GitHub Desktop.
type UserId = string & Nominal<UserId>;
type NodeId = string & Nominal<NodeId>;
interface User {
id: UserId;
name?: string;
address?: string;
}
interface Node {
id: NodeId;
x?: number;
y?: number;
}
// ❌ Type 'User' is not assignable to type 'Node'.
// Types of property 'id' are incompatible.
const node: Node = user;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment