Skip to content

Fix regression for optional JSDoc types which throws TS2463 in typescript@next #50286

Closed
@voxpelli

Description

@voxpelli

Bug Report

🔎 Search Terms

optional jsdoc regression

🕗 Version & Regression Information

This started occurring in nightly after #50094 was merged to fix #49869 and still happens (see these cron job type checks in pony-cause which retests against nightly three times a week).

This does not happen in 4.8 beta

  • This changed between versions 4.8-beta and nightly

⏯ Playground Link

Since the Playground is for TS code, not JS code, here's a link to a piece of code: https://github.com/voxpelli/pony-cause/blob/4009048a41d772cb29673f1c45cc55e9717e523f/lib/error-with-cause.js#L5-L9

And more in this thread: voxpelli/pony-cause#45

💻 Code

   /** 
    * @param {{ cause?: string }} [options] 
    */ 
   function foo ({ cause } = {}) { 

🙁 Actual behavior

Explicitly specifying the options as optional ([options] ) causes this error as it is already implicitly marked as optional by having been set a default value ({ cause } = {}):

error TS2463: A binding pattern parameter cannot be optional in an implementation signature.

🙂 Expected behavior

One of:

  1. Preferably that TypeScript keep accepting arguments that's been explicitly marked as optional, even if that is redundant
  2. At least change the error message to something that makes more sense in a JSDoc context than "A binding pattern parameter cannot be optional in an implementation signature."

See more in this thread: voxpelli/pony-cause#45 and in #50094 (comment), where @sandersn said that he is in favor the current new behavior.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptDomain: JSDocRelates to JSDoc parsing and type generationFix AvailableA PR has been opened for this issueRescheduledThis issue was previously scheduled to an earlier milestone

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions