@@ -56010,6 +56010,10 @@ var ts;
5601056010 var indexSymbol = symbol && getIndexSymbol(symbol);
5601156011 return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind);
5601256012 }
56013+ function getIndexDeclarationOfSymbolTable(symbolTable, kind) {
56014+ var indexSymbol = symbolTable && getIndexSymbolFromSymbolTable(symbolTable);
56015+ return indexSymbol && getIndexDeclarationOfIndexSymbol(indexSymbol, kind);
56016+ }
5601356017 function getIndexDeclarationOfIndexSymbol(indexSymbol, kind) {
5601456018 var syntaxKind = kind === 1 /* Number */ ? 144 /* NumberKeyword */ : 147 /* StringKeyword */;
5601556019 if (indexSymbol === null || indexSymbol === void 0 ? void 0 : indexSymbol.declarations) {
@@ -63218,14 +63222,17 @@ var ts;
6321863222 return type.flags & 32768 /* Undefined */ ? type : getUnionType([type, undefinedType]);
6321963223 }
6322063224 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 */);
6322163229 if (!deferredGlobalNonNullableTypeAlias) {
6322263230 deferredGlobalNonNullableTypeAlias = getGlobalSymbol("NonNullable", 524288 /* TypeAlias */, /*diagnostic*/ undefined) || unknownSymbol;
6322363231 }
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;
6322963236 }
6323063237 function getNonNullableType(type) {
6323163238 return strictNullChecks ? getGlobalNonNullableTypeInstantiation(type) : type;
@@ -66813,7 +66820,7 @@ var ts;
6681366820 !isGenericIndexType(getTypeOfExpression(parent.argumentExpression));
6681466821 }
6681566822 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 */) );
6681766824 }
6681866825 function containsGenericType(type) {
6681966826 return !!(type.flags & 465829888 /* Instantiable */ || type.flags & 3145728 /* UnionOrIntersection */ && ts.some(type.types, containsGenericType));
@@ -78287,21 +78294,24 @@ var ts;
7828778294 checkBlock(node.finallyBlock);
7828878295 }
7828978296 }
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 */);
7829378301 var stringIndexType = getIndexTypeOfType(type, 0 /* String */);
7829478302 var numberIndexType = getIndexTypeOfType(type, 1 /* Number */);
7829578303 if (stringIndexType || numberIndexType) {
7829678304 ts.forEach(getPropertiesOfObjectType(type), function (prop) {
78305+ if (isStatic && prop.flags & 4194304 /* Prototype */)
78306+ return;
7829778307 var propType = getTypeOfSymbol(prop);
7829878308 checkIndexConstraintForProperty(prop, propType, type, declaredStringIndexer, stringIndexType, 0 /* String */);
7829978309 checkIndexConstraintForProperty(prop, propType, type, declaredNumberIndexer, numberIndexType, 1 /* Number */);
7830078310 });
7830178311 var classDeclaration = type.symbol.valueDeclaration;
7830278312 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];
7830578315 // Only process instance properties with computed names here.
7830678316 // Static properties cannot be in conflict with indexers,
7830778317 // and properties with literal names were already checked.
@@ -78631,7 +78641,7 @@ var ts;
7863178641 }
7863278642 if (produceDiagnostics) {
7863378643 checkIndexConstraints(type);
78634- checkIndexConstraints(staticType);
78644+ checkIndexConstraints(staticType, /*isStatic*/ true );
7863578645 checkTypeForDuplicateIndexSignatures(node);
7863678646 checkPropertyInitialization(node);
7863778647 }
0 commit comments