Microsoft/TypeScript

Improve error when parameter is missing a name

Open

#22,203 opened on Feb 27, 2018

View on GitHub
 (6 comments) (1 reaction) (0 assignees)TypeScript (48,455 stars) (6,726 forks)batch import
Domain: Error MessagesHelp WantedSuggestion

Description

TypeScript Version: 2.8.0-dev.20180227 Code

declare class C {
    f({ x?: number }): void;
    g(): void;
}

Expected behavior:

At the ?, property in destructuring may not be marked optional.

Actual behavior:

src/a.ts(2,10): error TS1005: ',' expected.
src/a.ts(2,20): error TS1005: ',' expected.
src/a.ts(2,21): error TS1128: Declaration or statement expected.
src/a.ts(2,22): error TS1128: Declaration or statement expected.
src/a.ts(2,28): error TS1109: Expression expected.
src/a.ts(3,8): error TS1005: ';' expected.
src/a.ts(3,14): error TS1109: Expression expected.
src/a.ts(4,1): error TS1128: Declaration or statement expected.

Contributor guide

Improve error when parameter is missing a name · Microsoft/TypeScript#22203 | Good First Issue