Skip to content

Binding element incorrectly reported as having any type in JS with JSDoc starting with 5.6.2Β #59936

Closed
@burtek

Description

@burtek

πŸ”Ž Search Terms

Binding element implicitly has an any type 7031

πŸ•— Version & Regression Information

  • This changed between versions 5.5.4 and 5.6.2

⏯ 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

/**
 * @param {Object} [config]
 * @param {Partial<Record<'json' | 'jsonc' | 'json5', string[]>>} [config.additionalFiles]
 */
export function prepareConfig({
    additionalFiles: {
        json = []
    } = {}
} = {}) {
    console.log(json)
}

πŸ™ Actual behavior

json is errored as Binding element 'json' implicitly has an 'any[]' type.(7031) even though it's typed as string[]

image

πŸ™‚ Expected behavior

No error expected, as json is typed as string[]

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScript

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions