Skip to content

Impossible to annotate parameter properties in an isolatedDeclarations compatible wayΒ #60123

Closed
@blickly

Description

@blickly

πŸ”Ž Search Terms

isolatedDeclarations, parameter properties, implicit undefined

πŸ•— Version & Regression Information

  • Present since isolatedDeclarations was added in TS5.5

⏯ Playground Link

https://www.typescriptlang.org/play/?downlevelIteration=true&importHelpers=true&target=99&module=1&isolatedDeclarations=true&noCheck=true&exactOptionalPropertyTypes=true&ssl=3&ssc=2&pln=1&pc=1#code/KYDwDg9gTgLgBAYwDYEMDOa4CEVTgbwCg4TEIA7NGKAVwRmgAowoBLANxRmDhAH4AXHACCUKCgCecAD5wa5ACbAAZq3LAFASgIBfQjqA

πŸ’» Code

export class Bar {
    constructor(private x?: Array | undefined) {}
}

πŸ™ Actual behavior

Error:

Declaration emit for this parameter requires implicitly adding undefined to it's type. This is not supported with --isolatedDeclarations.

πŸ™‚ Expected behavior

Should not give an error since the undefined is already explicit.

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Help WantedYou can do thisPossible ImprovementThe current behavior isn't wrong, but it's possible to see that it might be better in some cases

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions