Created
May 31, 2022 05:32
-
-
Save ehatricksmith/43a1131c4025848f2cd1802a6449a723 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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