@@ -142,7 +142,6 @@ namespace ts {
142
142
const voidType = createIntrinsicType(TypeFlags.Void, "void");
143
143
const neverType = createIntrinsicType(TypeFlags.Never, "never");
144
144
const silentNeverType = createIntrinsicType(TypeFlags.Never, "never");
145
- const stringOrNumberType = getUnionType([stringType, numberType]);
146
145
147
146
const emptyObjectType = createAnonymousType(undefined, emptySymbols, emptyArray, emptyArray, undefined, undefined);
148
147
@@ -3219,6 +3218,8 @@ namespace ts {
3219
3218
3220
3219
// A variable declared in a for..in statement is always of type string
3221
3220
if (declaration.parent.parent.kind === SyntaxKind.ForInStatement) {
3221
+ // const indexType = getIndexType(checkNonNullExpression((<ForInStatement>declaration.parent.parent).expression));
3222
+ // return indexType.flags & TypeFlags.Index ? indexType : stringType;
3222
3223
return stringType;
3223
3224
}
3224
3225
@@ -4688,7 +4689,6 @@ namespace ts {
4688
4689
t.flags & TypeFlags.NumberLike ? globalNumberType :
4689
4690
t.flags & TypeFlags.BooleanLike ? globalBooleanType :
4690
4691
t.flags & TypeFlags.ESSymbol ? getGlobalESSymbolType() :
4691
- t.flags & TypeFlags.Index ? stringOrNumberType :
4692
4692
t;
4693
4693
}
4694
4694
@@ -5920,8 +5920,7 @@ namespace ts {
5920
5920
function getIndexType(type: Type): Type {
5921
5921
return type.flags & TypeFlags.TypeParameter ? getIndexTypeForTypeParameter(<TypeParameter>type) :
5922
5922
getObjectFlags(type) & ObjectFlags.Mapped ? getConstraintTypeFromMappedType(<MappedType>type) :
5923
- type.flags & TypeFlags.Any || getIndexInfoOfType(type, IndexKind.String) ? stringOrNumberType :
5924
- getIndexInfoOfType(type, IndexKind.Number) ? getUnionType([numberType, getLiteralTypeFromPropertyNames(type)]) :
5923
+ type.flags & TypeFlags.Any || getIndexInfoOfType(type, IndexKind.String) ? stringType :
5925
5924
getLiteralTypeFromPropertyNames(type);
5926
5925
}
5927
5926
@@ -6040,10 +6039,9 @@ namespace ts {
6040
6039
return indexedAccessTypes[id] || (indexedAccessTypes[id] = createIndexedAccessType(objectType, indexType));
6041
6040
}
6042
6041
const apparentObjectType = getApparentType(objectType);
6043
- const apparentIndexType = indexType.flags & TypeFlags.Index ? stringOrNumberType : indexType;
6044
- if (apparentIndexType.flags & TypeFlags.Union && !(apparentIndexType.flags & TypeFlags.Primitive)) {
6042
+ if (indexType.flags & TypeFlags.Union && !(indexType.flags & TypeFlags.Primitive)) {
6045
6043
const propTypes: Type[] = [];
6046
- for (const t of (<UnionType>apparentIndexType ).types) {
6044
+ for (const t of (<UnionType>indexType ).types) {
6047
6045
const propType = getPropertyTypeForIndexType(apparentObjectType, t, accessNode, /*cacheSymbol*/ false);
6048
6046
if (propType === unknownType) {
6049
6047
return unknownType;
@@ -6052,7 +6050,7 @@ namespace ts {
6052
6050
}
6053
6051
return getUnionType(propTypes);
6054
6052
}
6055
- return getPropertyTypeForIndexType(apparentObjectType, apparentIndexType , accessNode, /*cacheSymbol*/ true);
6053
+ return getPropertyTypeForIndexType(apparentObjectType, indexType , accessNode, /*cacheSymbol*/ true);
6056
6054
}
6057
6055
6058
6056
function getTypeFromIndexedAccessTypeNode(node: IndexedAccessTypeNode) {
@@ -7124,16 +7122,6 @@ namespace ts {
7124
7122
7125
7123
if (isSimpleTypeRelatedTo(source, target, relation, reportErrors ? reportError : undefined)) return Ternary.True;
7126
7124
7127
- if (source.flags & TypeFlags.Index) {
7128
- // A keyof T is related to a union type containing both string and number
7129
- const related = relation === comparableRelation ?
7130
- maybeTypeOfKind(target, TypeFlags.String | TypeFlags.Number) :
7131
- maybeTypeOfKind(target, TypeFlags.String) && maybeTypeOfKind(target, TypeFlags.Number);
7132
- if (related) {
7133
- return Ternary.True;
7134
- }
7135
- }
7136
-
7137
7125
if (getObjectFlags(source) & ObjectFlags.ObjectLiteral && source.flags & TypeFlags.FreshLiteral) {
7138
7126
if (hasExcessProperties(<FreshObjectLiteralType>source, target, reportErrors)) {
7139
7127
if (reportErrors) {
@@ -15654,7 +15642,7 @@ namespace ts {
15654
15642
const type = <MappedType>getTypeFromMappedTypeNode(node);
15655
15643
const constraintType = getConstraintTypeFromMappedType(type);
15656
15644
const keyType = constraintType.flags & TypeFlags.TypeParameter ? getApparentTypeOfTypeParameter(<TypeParameter>constraintType) : constraintType;
15657
- checkTypeAssignableTo(keyType, stringOrNumberType , node.typeParameter.constraint);
15645
+ checkTypeAssignableTo(keyType, stringType , node.typeParameter.constraint);
15658
15646
}
15659
15647
15660
15648
function isPrivateWithinAmbient(node: Node): boolean {
0 commit comments