mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-09 20:51:43 -06:00
Make keyof T assignable to and subtype of string | number
This commit is contained in:
parent
7ca5923214
commit
a562d6e63f
@ -6917,6 +6917,13 @@ namespace ts {
|
||||
|
||||
if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return Ternary.True;
|
||||
|
||||
if (source.flags & TypeFlags.Index) {
|
||||
// A keyof T is related to a union type containing both string and number
|
||||
if (maybeTypeOfKind(target, TypeFlags.String) && maybeTypeOfKind(target, TypeFlags.Number)) {
|
||||
return Ternary.True;
|
||||
}
|
||||
}
|
||||
|
||||
if (getObjectFlags(source) & ObjectFlags.ObjectLiteral && source.flags & TypeFlags.FreshLiteral) {
|
||||
if (hasExcessProperties(<FreshObjectLiteralType>source, target, reportErrors)) {
|
||||
if (reportErrors) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user