-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Binding element incorrectly reported as having any
type in JS with JSDoc starting with 5.6.2
#59936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'll fix this as part of #59924 |
@Andarist ok, thanks. I guess it's gonna go out as 5.6 patch bump? |
@burtek in the end I decided to create a separate PR for this one since I was able to fix this independently and the other PR raises some design questions. The fix is available here: #59975 As to your question, this is a recent regression so I'd advocate to bacport a fix to 5.6 but that's up to the TS team. |
This issue actually existed before 5.6, but only for array binding patterns (playground link): /**
* @param {[[string[]?]?]} [x]
*/
function f1([[json = []] = []] = []) { return json } // Implicit any[] error on json binding element In 5.6 we aligned array and object literal padding and the issue then showed up in object binding patterns as well: /**
* @param {{ a?: { json?: string[] }}} [x]
*/
function f2({ a: { json = [] } = {} } = {}) { return json } // Implicit any[] error on json binding element The culprit here is logic we have in |
π Search Terms
Binding element implicitly has an any type 7031
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?strictNullChecks=true&target=9&suppressImplicitAnyIndexErrors=true&ts=5.6.2&filetype=js#code/PQKhCgAIUgBAHAhgJ0QW0gbwPICMBWApgMYAuAvpANrED2AdgGYCWA5gLpQwIrpYAKKUs0QAbADwAlErWQATcQHJ8AZwaLIAH0jK19Yhu26GAVkUAaSCtLJm9VlXYA+J5RoMWrAHSI5c5sIMYgBizKKEKpzQwOCEAB7wsqSQjACu+oH0kPDIhEi5AMIebAAUmFCQlb7+mSFhEQBcWBWVrZCqDJAAvNRRrZQ9mOTgA1jkAJTNbXT0auFeorSsJR304yNAA
π» Code
π Actual behavior
json
is errored asBinding element 'json' implicitly has an 'any[]' type.(7031)
even though it's typed asstring[]
π Expected behavior
No error expected, as
json
is typed asstring[]
Additional information about the issue
This worked well in 5.5.4 but broke with upgrade to 5.6.2. It works correctly in .ts file, but breaks in .js file with JSDoc.
The text was updated successfully, but these errors were encountered: