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
{{ message }}
Repository navigation
Generic constraints cannot be applied to template literalsΒ #55493
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'.
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.
Activity
fatcerberus commentedon Aug 24, 2023
test0is 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.typescript-bot commentedon Aug 27, 2023
This issue has been marked as "Working as Intended" and has seen no recent activity. It has been automatically closed for house-keeping purposes.