Last active
June 26, 2021 09:43
-
-
Save magurotuna/a35b83de6e70c53b9d5322fc2d51addd 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
// https://github.com/denoland/deno_doc/pull/105 | |
export function f1(val1: A | B): val1 is A {} | |
export function f2(val2: any): asserts val2 is string {} | |
export function f3(val3: any): asserts val3 {} | |
export function assertIsDefined<T>(val4: T): asserts val4 is NonNullable<T> { | |
if (val === undefined || val === null) { | |
throw new AssertionError( | |
`Expected 'val' to be defined, but received ${val}` | |
); | |
} | |
} | |
export class C { | |
isSomething(): this is Something { | |
return this instanceof Something; | |
} | |
} | |
export type A = string | number; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment