Skip to content

More helpful error message when using default as parameter name? #16934

Description

@mqudsi

Under TypeScript 2.4.0, the following code returns a not-quite-helpful error message:

function Coalesce<T>(t: T, default: T) {
	return t != null ? t : default;
}

The errors are

script.ts(1,28): error TS1003: Identifier expected.
script.ts(2,21): error TS1109: Expression expected.
script.ts(2,29): error TS1128: Declaration or statement expected.

Obviously the actual error here is the use of the reserved keyword default as a parameter name.

Is there a valid usage for default in the parameter list or can this be caught and turned into a more helpful message such as Use of reserved keyword "default" as parameter name. or similar?

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptDomain: Error MessagesThe issue relates to error messagingGood First IssueWell scoped, documented and has the green lightHelp WantedYou can do this

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions