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

support generic type when checking implicit conversion of symbol to string #44578

Merged
merged 2 commits into from
Mar 4, 2022

Conversation

Zzzen
Copy link
Contributor

@Zzzen Zzzen commented Jun 14, 2021

Fixes #44462

When fixing this bug, I find bigint has the same problem.

playground

type numberOrBigint = number | bigint;

function getKey(key: numberOrBigint) {
    +key;   // ✔ should error, and the compiler does
    0 + key;  // ✔ should error, and the compiler does
}

function getKey2<S extends numberOrBigint>(key: S) {
    +key;  // ❌ should error , but the compiler does not
    0 + key;   // ✔ should error, and the compiler does
}

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jun 14, 2021
@Zzzen Zzzen changed the title support generic type when checking implicit conversion of symbol to s… support generic type when checking implicit conversion of symbol to string Jun 14, 2021
@weswigham weswigham merged commit f9ae305 into microsoft:main Mar 4, 2022
@DanielRosenwasser DanielRosenwasser added the Breaking Change Would introduce errors in existing code label Apr 26, 2022
@theonlypwner
Copy link

bigint still has the same problem in playground on v4.74 and v4.8.0-beta

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Breaking Change Would introduce errors in existing code For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Generic type extending symbol do not prevent usage of the value in template literal
5 participants