Skip to content

Satisfies operator affects type inference for SymbolΒ #61070

@yoshi-pi

Description

@yoshi-pi

πŸ”Ž Search Terms

"Symbol", "satisfies", "type inference"

πŸ•— Version & Regression Information

  • This changed between versions v4.9 and latest

⏯ Playground Link

https://www.typescriptlang.org/play/?#code/MYewdgzgLgBAZiEMC8MDKBPAtgIxAGwAoBKAbhgHoKYAVACwFMYoMAHJkOeRGASwmZsGnbiABQoSLBwBDAE4p02PEWIwIMqPzi8GAiMoLkqtRoPYwRshf3WH8QA

πŸ’» Code

const foo = Symbol(); // The type of foo is typeof foo
const bar = Symbol() satisfies symbol; // The type of bar is symbol

πŸ™ Actual behavior

Using the satisfies operator with Symbol changes the type of bar to symbol, instead of typeof foo.

πŸ™‚ Expected behavior

I expected the satisfies operator to have no effect on type inference, so bar should have the type typeof bar.

Additional information about the issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Not a DefectThis behavior is one of several equally-correct options

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions