Opaque type for SemVer ranges.
Use assertIsSemVerRange and isValidSemVerRange to cast to proper type.
const unsafeRange: string = dataFromUser();assertIsSemVerRange(unsafeRange);unsafeRange// ^? SemVerRange
If you know what you're doing and want to side-step type safety, casting from a string works correctly.
const unsafeRange: string = dataFromUser();unsafeRange as SemVerRange;// ^? SemVerRange
Opaque type for SemVer ranges.
Example
Use assertIsSemVerRange and isValidSemVerRange to cast to proper type.
Example
If you know what you're doing and want to side-step type safety, casting from a string works correctly.
See