Skip to content

Generic type extending symbol do not prevent usage of the value in template literalΒ #44462

Description

Bug Report

πŸ”Ž Search Terms

bug extends symbols template literal

πŸ•— Version & Regression Information

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about symbols

⏯ Playground Link

Playground link with relevant code

πŸ’» Code

type StringOrSymbol = string | symbol;

function getKey(key: StringOrSymbol) {

    return `${key} is the key`; // Error: Implicit conversion of a 'symbol' to a 'string' will fail at runtime.
}

function getKey2<S extends StringOrSymbol>(key: S) {

    return `${key} is the key`; // No error
}

πŸ™ Actual behavior

When using a value of a generic type that extends symbol there is no error on usage in template literal.

πŸ™‚ Expected behavior

It is expected that the error "Implicit conversion of a 'symbol' to a 'string' will fail at runtime." is thrown when using a generic type that extends symbol in a template literal.

No activity

Activity on this issue will appear here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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