Skip to content

Trailing comma in type alias causes TS1003 identifier expected compiler error #2509

Closed
@0xJem

Description

@0xJem

Sample code

This causes a TS1003 error on the comma after the third parameter:

export type PriceLookup = (
  tokenAddress: string,
  block: i32,
  currentPool: string,
) => string | null;
ERROR TS1003: Identifier expected.
;;    :
;;  4 │ currentPool: string,
;;    │                    ^
;;    └─ in module.ts(4,22)
;; 
;; ERROR TS1012: Unexpected token.
;;    :
;;  4 │ currentPool: string,
;;    │                    ^
;;    └─ in module.ts(4,22)

This compiles fine:

export type PriceLookup2 = (tokenAddress: string, block: i32, currentPool: string) => string | null;

Functionally, there is no difference between these. However, eslint/prettier will often cause example 2 to be wrapped into the format of example 1, so it would be nice for this to not error.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions