Skip to content

[ID-Prep] Type of variable is widened in declaration with !strictNullChecksΒ #57441

Open
@dragomirtitian

Description

@dragomirtitian

The [ID-prep] set of issues aligns Declaration Emit with the forthcoming Isolated Declarations feature.

πŸ”Ž Search Terms

const declaration widen

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried

⏯ Playground Link

Playground Link

πŸ’» Code

declare function f3<T>(a: T, b: T): T;
const x3 = f3("abc", "def");  // "abc" | "def"

πŸ™ Actual behavior

x3 is emitted as declare const x3: string; in declaration files but it's actually "abc" | "def" in source

πŸ™‚ Expected behavior

x3 is emitted as declare const x3: "abc" | "def"

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Domain: Isolated DeclarationsRelated to the --isolatedDeclarations compiler flagHelp 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