Skip to content

[isolatedDeclarations] --isolatedDeclarations gives incorrect error when a parameter property with default value is followed by required parameterΒ #60976

@blickly

Description

@blickly

πŸ”Ž Search Terms

isolatedDeclarations, optional parameter properties, default value, spurious error

πŸ•— Version & Regression Information

  • This changed between versions 5.5.4 and 5.6.3

⏯ Playground Link

https://www.typescriptlang.org/play/?isolatedDeclarations=true&ts=5.7.3#code/MYGwhgzhAEBCYCdoG8C+AodBTAHgBwHsEAXaUSGAMQIJXWgbIIDsJiEBXYYogCnsaC8CAJYA3MMSzRECAFxxE0ALzRmWAO6KEvAJQAaAYIbDxk6QCMaIBVYIgsYZocG6UGVEA

πŸ’» Code

class Bar {}

export class Foo {
    constructor(
        private arr: Bar = new Bar(),
        private bool: boolean,
    ) {}
}

πŸ™ Actual behavior

Parameter must have an explicit type annotation with --isolatedDeclarations.

referring to the RHS new Bar()

πŸ™‚ Expected behavior

Should be no error, as the parameter is already annotated.

Additional information about the issue

@dragomirtitian FYI

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptHelp WantedYou can do this

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions