Skip to content

No error in JavaScript on optional binding pattern parameterΒ #49869

@jespertheend

Description

@jespertheend

Bug Report

πŸ”Ž Search Terms

TS2463 javascript

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about default

⏯ Playground Link

πŸ’» Code

/**
 * @param [options]
 */
function test({ x = '' }) { x }

πŸ™ Actual behavior

No error on { x = '' }.

πŸ™‚ Expected behavior

Error 2463: "A binding pattern parameter cannot be optional in an implementation signature."

The equivalent Typescript has the correct error:

function test({ x = '' }?) { x }

Note that in the playground link I have checked all options that are supposed to make types more strict. Also note that when this code is run, you'll end up with a runtime error. The same is true for the TypeScript equivalent, but in that case you get an error in advance warning you that the code you wrote will cause issues.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueGood First IssueWell scoped, documented and has the green light

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions