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

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

Closed
micnic opened this issue Jun 6, 2021 · 0 comments Β· Fixed by #44578
Closed

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

micnic opened this issue Jun 6, 2021 · 0 comments Β· Fixed by #44578
Labels
Bug A bug in TypeScript Help Wanted You can do this
Milestone

Comments

@micnic
Copy link
Contributor

micnic commented Jun 6, 2021

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.

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
Development

Successfully merging a pull request may close this issue.

2 participants