Skip to content

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

Closed
@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

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions