8000 typescript: empty typeParameters and typeArguments · Issue #5839 · prettier/prettier · GitHub
[go: up one dir, main page]

Skip to content
typescript: empty typeParameters and typeArguments #5839
@armano2

Description

@armano2

Prettier 1.16.4

Due to inconsistency in reported ast by typescript parser, there is issue with some of typeParameters and typeArguments, in some cases parser outputs TSTypeParameterInstantiation and TSTypeParameterDeclaration with empty array of params

in PR https://github.com/typescript-eslint/typescript-eslint/pull/223i proposed change to make all occurrences of this consistent across all nodes. It means that all occurrences of <> are going to lead to crash in this package, as opposed to only sometimes.

TSTypeParameterInstantiation and TSTypeParameterDeclaration with empty array of params should be supported

Playground link
AST Structure

Input:

interface foo {
    foo<>();
}

Output:

TypeError: Cannot read property 'pos' of undefined
    at https://prettier.io/lib/parser-typescript.js:1:2122250
    at T (https://prettier.io/lib/parser-typescript.js:1:2123933)
    at t (https://prettier.io/lib/parser-typescript.js:1:2122204)
    at Object.h [as findNextToken] (https://prettier.io/lib/parser-typescript.js:1:2122387)
    at b (https://prettier.io/lib/parser-typescript.js:1:2128676)
    at e (https://prettier.io/lib/parser-typescript.js:1:2155613)
    at d (https://prettier.io/lib/parser-typescript.js:1:2127555)
    at m (https://prettier.io/lib/parser-typescript.js:1:2127698)
    at https://prettier.io/lib/parser-typescript.js:1:2157681
    at Array.map (<anonymous>)

Reference:

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.type:testsIssues about tests that are not correct, should be added, or similar

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0