You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regression in 7.1: contextual parameter type is lost for a destructuring pattern with a default (TS7031) #65011
a.js(6,26): error TS7031: Binding element 'signal' implicitly has an 'any' type.
🙂 Expected behavior
No error: signal is typed AbortSignal | undefined from the contextual Opts, as in 5.9 and 7.0.
Notes
Destructuring is not generally broken. Removing the = {} default keeps it working, and so does taking a named parameter and destructuring it in the body:
asyncstructure(c,opts){const{ signal }=opts??{};signal?.throwIfAborted();return[c]}
Tagging the parameters explicitly makes 7.1 accept the method again, so a workaround exists for callers who hit it:
/** @param {string} c @param {Opts} [o] */asyncstructure(c,{ signal }={}){…}
Not specific to JavaScript or JSDoc. The same shape in .ts fails too:
typeO={signal?: AbortSignal}constf: (o?: O)=>void=({ signal }={})=>{signal?.throwIfAborted()}
7.1.0-beta reports TS7031 here; 5.9.3 and 7.0.2 do not.
changed the title [-]JS regression in 7.1: JSDoc contextual parameter type is lost for a destructuring pattern with a default (TS7031)[/-][+]Regression in 7.1: contextual parameter type is lost for a destructuring pattern with a default (TS7031)[/+]on Oct 29, 2026
It skips object/tuple padding in checkDeclarationInitializer when the parameter already has a contextual type (same idea as #64978), also guards array binding patterns, and adds compiler tests for the JSDoc @returns / cast / .ts shapes from this issue.
Activity
[-]JS regression in 7.1: JSDoc contextual parameter type is lost for a destructuring pattern with a default (TS7031)[/-][+]Regression in 7.1: contextual parameter type is lost for a destructuring pattern with a default (TS7031)[/+]timurzvural commentedon Oct 29, 2026
Opened an alternative fix in #65016.
It skips object/tuple padding in
checkDeclarationInitializerwhen the parameter already has a contextual type (same idea as #64978), also guards array binding patterns, and adds compiler tests for the JSDoc@returns/ cast /.tsshapes from this issue.MartinJohns commentedon Oct 29, 2026
Duplicate of #64974.