@@ -56010,6 +56010,10 @@ var ts;
56010
56010
var indexSymbol = symbol && getIndexSymbol(symbol);
56011
56011
return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind);
56012
56012
}
56013
+ function getIndexDeclarationOfSymbolTable(symbolTable, kind) {
56014
+ var indexSymbol = symbolTable && getIndexSymbolFromSymbolTable(symbolTable);
56015
+ return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind);
56016
+ }
56013
56017
function getIndexDeclarationOfIndexSymbol(indexSymbol, kind) {
56014
56018
var syntaxKind = kind === 1 /* Number */ ? 144 /* NumberKeyword */ : 147 /* StringKeyword */;
56015
56019
if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
@@ -63218,14 +63222,17 @@ var ts;
63218
63222
return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]);
63219
63223
}
63220
63224
function getGlobalNonNullableTypeInstantiation(type) {
63225
+ // First reduce away any constituents that are assignable to 'undefined' or 'null'. This not only eliminates
63226
+ // 'undefined' and 'null', but also higher-order types such as a type parameter 'U extends undefined | null'
63227
+ // that isn't eliminated by a NonNullable<T> instantiation.
63228
+ var reducedType = getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */);
63221
63229
if (!deferredGlobalNonNullableTypeAlias) {
63222
63230
deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
63223
63231
}
63224
- // Use NonNullable global type alias if available to improve quick info/declaration emit
63225
- if (deferredGlobalNonNullableTypeAlias !== unknownSymbol) {
63226
- return getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [type]);
63227
- }
63228
- return getTypeWithFacts(type, 2097152 /* NEUndefinedOrNull */); // Type alias unavailable, fall back to non-higher-order behavior
63232
+ // If the NonNullable<T> type is available, return an instantiation. Otherwise just return the reduced type.
63233
+ return deferredGlobalNonNullableTypeAlias !== unknownSymbol ?
63234
+ getTypeAliasInstantiation(deferredGlobalNonNullableTypeAlias, [reducedType]) :
63235
+ reducedType;
63229
63236
}
63230
63237
function getNonNullableType(type) {
63231
63238
return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
@@ -66813,7 +66820,7 @@ var ts;
66813
66820
!isGenericIndexType(getTypeOfExpression(parent.argumentExpression));
66814
66821
}
66815
66822
function isGenericTypeWithUnionConstraint(type) {
66816
- return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & 1048576 /* Union */);
66823
+ return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */) );
66817
66824
}
66818
66825
function containsGenericType(type) {
66819
66826
return !!(type.flags & 465829888 /* Instantiable */ || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, containsGenericType));
@@ -78287,21 +78294,24 @@ var ts;
78287
78294
checkBlock(node.finallyBlock);
78288
78295
}
78289
78296
}
78290
- function checkIndexConstraints(type) {
78291
- var declaredNumberIndexer = getIndexDeclarationOfSymbol(type.symbol, 1 /* Number */);
78292
- var declaredStringIndexer = getIndexDeclarationOfSymbol(type.symbol, 0 /* String */);
78297
+ function checkIndexConstraints(type, isStatic) {
78298
+ var _a, _b, _c, _d;
78299
+ var declaredNumberIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_a = type.symbol) === null || _a === void 0 ? void 0 : _a.exports : (_b = type.symbol) === null || _b === void 0 ? void 0 : _b.members, 1 /* Number */);
78300
+ var declaredStringIndexer = getIndexDeclarationOfSymbolTable(isStatic ? (_c = type.symbol) === null || _c === void 0 ? void 0 : _c.exports : (_d = type.symbol) === null || _d === void 0 ? void 0 : _d.members, 0 /* String */);
78293
78301
var stringIndexType = getIndexTypeOfType(type, 0 /* String */);
78294
78302
var numberIndexType = getIndexTypeOfType(type, 1 /* Number */);
78295
78303
if (stringIndexType || numberIndexType) {
78296
78304
ts.forEach(getPropertiesOfObjectType(type), function (prop) {
78305
+ if (isStatic && prop.flags & 4194304 /* Prototype */)
78306
+ return;
78297
78307
var propType = getTypeOfSymbol(prop);
78298
78308
checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */);
78299
78309
checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */);
78300
78310
});
78301
78311
var classDeclaration = type.symbol.valueDeclaration;
78302
78312
if (ts.getObjectFlags(type) & 1 /* Class */ && classDeclaration && ts.isClassLike(classDeclaration)) {
78303
- for (var _i = 0, _a = classDeclaration.members; _i < _a .length; _i++) {
78304
- var member = _a [_i];
78313
+ for (var _i = 0, _e = classDeclaration.members; _i < _e .length; _i++) {
78314
+ var member = _e [_i];
78305
78315
// Only process instance properties with computed names here.
78306
78316
// Static properties cannot be in conflict with indexers,
78307
78317
// and properties with literal names were already checked.
@@ -78631,7 +78641,7 @@ var ts;
78631
78641
}
78632
78642
if (produceDiagnostics) {
78633
78643
checkIndexConstraints(type);
78634
- checkIndexConstraints(staticType);
78644
+ checkIndexConstraints(staticType, /*isStatic*/ true );
78635
78645
checkTypeForDuplicateIndexSignatures(node);
78636
78646
checkPropertyInitialization(node);
78637
78647
}
0 commit comments