Skip to content

String templates doesn't work with nested generics and keyof #56582

@f3oall

Description

@f3oall

🔎 Search Terms

String templates doesn't work with nested generics and keyof

🕗 Version & Regression Information

5.2.2, 5.3

⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.3.2#code/JYOwLgpgTgZghgYwgAgIIB4AqyIA9IgAmAzsgEoQID2Uh6xYUoA5gDTINMjMB8yA3gChkyEBAYRCALmSZBAX0FKYAVxAIwwKiGRwsOfBCKkM-YNI6MW8njwAUYGZgCUA4cgBGD9gHJzP1wB6QORmKipCdy8wXwBafyCQgCEVZgB+BUFVdU1tT308AhI0dDgQAE9bByd2YhpHZABrCHKqGFkAbR8xCUIfAF1kADJLLmZkAB9kAANYgBJ+Ztb2zC6eyD7Bkc5radchTKA

💻 Code

interface A<T extends Record<string, string> {
  nested: T
}


function a<T extends A<{id: string}>>(t: T) {
  b(t, 'id') // good
  b(t, '-id') // Bug?
}
function b<T extends A<any>>(t: T, sort: keyof T['nested'] & string | `-${keyof T['nested'] & string}`) {

}

🙁 Actual behavior

Template string doesn't work as expected

🙂 Expected behavior

The example should compile without error

Additional information about the issue

No response

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions