Last active
April 23, 2021 14:32
-
-
Save alessioprestileo/330ba516d1e40c83ca75d23715345a60 to your computer and use it in GitHub Desktop.
Type definitions and constructors for units of measurement
This file contains hidden or 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
export type Meters = number & {__tagMeters: never}; | |
export type Feet = number & {__tagFeet: never}; | |
export type Measurement = Meters | Feet; | |
export function toMeasurement<T extends Measurement>(val: number): T {return val as T} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment