Skip to content

TypeScript: trailing commas after rest parameters in ambient contexts #13100

@thorn0

Description

@thorn0

Bug Report

Current behavior

Currently, Babel throws an unrecoverable syntax error whenever it finds a trailing comma after a rest parameter, however TypeScript allows such commas in ambient contexts (in declarations marked with declare or in .d.ts files).

Input Code

// in a .ts file
declare function foo(...args: any[],): any;

declare class Bar {
    foo(...args: any[],): any
}

declare interface Baz {
    foo(...args: any[],): any
}

declare type Q = (...args: any[],) => any

// in a .d.ts file
function foo(...args: any[],): any;

class Bar {
    foo(...args: any[],): any
}

interface Baz {
    foo(...args: any[],): any
}

type Q = (...args: any[],) => any

Expected behavior

No error

Environment

  • Babel version(s): v7.13.14

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions