Skip to content

[TypeScript 3.7] add support for asserts keyword #6574

@niedzielski

Description

@niedzielski

Prettier 1.18.2

TypeScript is developing support for assertions in control flow analysis. The functionality is now available in development builds such as v3.7.0-dev.20190928. This ticket requests enabling Prettier support of the new asserts keyword.

Playground link

--parser typescript

Input:

function assert(value: unknown): asserts value {
  throw new Error()
}

Output:

SyntaxError: '{' or ';' expected. (1:42)
> 1 | function assert(value: unknown): asserts value {
    |                                          ^
  2 |   throw new Error()
  3 | }
  4 | 

Expected behavior:

function assert(value: unknown): asserts value {
  throw new Error()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    lang:typescriptIssues affecting TypeScript-specific constructs (not general JS issues)locked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.scope:dependencyIssues that cannot be solved inside Prettier itself, and must be fixed in a dependency

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions