Skip to content

TypeScript assertion signatures #10527

@DanielRosenwasser

Description

@DanielRosenwasser

TypeScript 3.7 will support an asserts Identifier is Type syntax in function annotation positions (much like with type predicates).

declare function assertIsFoo(x): asserts x is Foo;

function assertIsDefined<T>(x: T): asserts x is NonNullable<T> {
    if (x == null) throw "oh no";
}

See more at the original pull request: microsoft/TypeScript#32695

Metadata

Metadata

Assignees

Labels

Has PRarea: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issue

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions