Skip to content

typescript: TSIndexSignature with multiple parameters  #7224

@armano2

Description

@armano2

TSIndexSignature allows to output multiple parameters, this syntax is no longer valid, but typescript produces ast for it

Prettier 1.19.1
Playground link

--parser typescript

Input:
source

type foo = {
  [a: string, b: string]: string;
}

Output:

type foo = {
  [a: stringb: string]: string;
};

Expected behavior:

type foo = {
  [a: string, b: string]: string;
}

Additional info

https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/typescript-estree/src/ts-estree/ts-estree.ts#L1336-L1344

export interface TSIndexSignature extends BaseNode {
  type: AST_NODE_TYPES.TSIndexSignature;
  parameters: Parameter[];
  typeAnnotation?: TSTypeAnnotation;
  readonly?: boolean;
  accessibility?: Accessibility;
  export?: boolean;
  static?: boolean;
}

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions