You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
typetemplateLiteralObject=Record< `${string}_${string}`,any>// or { [k : `${string}_${string}`]: any }consttest0={aaa:123}satisfiestemplateLiteralObject// error: Type '{ aaa: number; }' does not satisfy the expected type 'templateLiteral'.The error is as expected .typefoo<TextendstemplateLiteralObject>=Ttypetest1=foo<{aaa:123}>// Hope this is an error. Because test0 will report an errortypetest2={aaa:123}extendstemplateLiteralObject ? true : false// also should be false,Currently is true
π Actual behavior
test0 throw errorοΌ Type '{ aaa: number; }' does not satisfy the expected type 'templateLiteral'.
but test1 No error reported
π Expected behavior
Hope test1 reported an error
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
test0 is an excess property check error, not a type error. In general, objects can have extra properties, so you canβt constrain the set of allowed keys. See #55152.
π Search Terms
Generic constraints
template literals
π Version & Regression Information
5.1.6
β― Playground Link
https://www.typescriptlang.org/play?ts=5.2.0-beta&ssl=9&ssc=111&pln=1&pc=1#code/C4TwDgpgBMELZgDYENYBkCWsBOzEHkAjAKwgGNgoBeKAJXIHtsATAHigAMASAbwGdg2DADsA5gF8A+rwFCx4jgBpkwkAD4oAek1QmUHlADaAaygAuTjMEiJ0-tfkcAuhZUgo4gFCeyDYQJgIAQAGan1kCLMARgAmAGZxKD5UDD4AMwwgwIQUdCwIXAISckptKALsJgsAFXBoAHIDCOQLYQBXOEICgG4PeqhmBizhBkpk4FS092AAC2gIAA9ICghmGDqoetgc1AhMHDx6gDpqufLsSuwoVKhkPnKlktWoI+9QSCg0hgZWaofYYTMe7bJC7fYFPBEUgUDQ0P5vDawARRMJfH48ZrReLiDRaHRQAASDA+sxuNxU50uRygACFyMg2nxoEjgKEAO4YRCIKDYCBgJiUCkVJgIklBYAxMIYyKxBL-CCA4HwUF5A5FaGUAD8MGwbWgFjSeCZeKgt0QfAYSRmDDaiDWXU+RogigAwm0LgrgIh3DdBHqgA
π» Code
π Actual behavior
test0 throw errorοΌ Type '{ aaa: number; }' does not satisfy the expected type 'templateLiteral'.
but test1 No error reported
π Expected behavior
Hope test1 reported an error
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered: