Skip to content
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

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

Closed
blickly opened this issue Jan 15, 2025 · 0 comments Β· Fixed by #60980
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@blickly
Copy link
Contributor

blickly commented Jan 15, 2025

πŸ”Ž 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Help Wanted You can do this
Projects
None yet
2 participants