typescript 5.7.0-dev.20240922 → 5.7.0-dev.20240924
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +136 -30
- package/lib/typescript.d.ts +1 -1
- package/lib/typescript.js +136 -30
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.7";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20240924`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -56412,11 +56412,20 @@ function createTypeChecker(host) {
|
|
|
56412
56412
|
return type;
|
|
56413
56413
|
}
|
|
56414
56414
|
function isLateBindableName(node) {
|
|
56415
|
+
return isLateBindableAST(node) && isTypeUsableAsPropertyName(isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(node.argumentExpression));
|
|
56416
|
+
}
|
|
56417
|
+
function isLateBindableIndexSignature(node) {
|
|
56418
|
+
return isLateBindableAST(node) && isTypeUsableAsIndexSignature(isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(node.argumentExpression));
|
|
56419
|
+
}
|
|
56420
|
+
function isLateBindableAST(node) {
|
|
56415
56421
|
if (!isComputedPropertyName(node) && !isElementAccessExpression(node)) {
|
|
56416
56422
|
return false;
|
|
56417
56423
|
}
|
|
56418
56424
|
const expr = isComputedPropertyName(node) ? node.expression : node.argumentExpression;
|
|
56419
|
-
return isEntityNameExpression(expr)
|
|
56425
|
+
return isEntityNameExpression(expr);
|
|
56426
|
+
}
|
|
56427
|
+
function isTypeUsableAsIndexSignature(type) {
|
|
56428
|
+
return isTypeAssignableTo(type, stringNumberSymbolType);
|
|
56420
56429
|
}
|
|
56421
56430
|
function isLateBoundName(name) {
|
|
56422
56431
|
return name.charCodeAt(0) === 95 /* _ */ && name.charCodeAt(1) === 95 /* _ */ && name.charCodeAt(2) === 64 /* at */;
|
|
@@ -56425,6 +56434,10 @@ function createTypeChecker(host) {
|
|
|
56425
56434
|
const name = getNameOfDeclaration(node);
|
|
56426
56435
|
return !!name && isLateBindableName(name);
|
|
56427
56436
|
}
|
|
56437
|
+
function hasLateBindableIndexSignature(node) {
|
|
56438
|
+
const name = getNameOfDeclaration(node);
|
|
56439
|
+
return !!name && isLateBindableIndexSignature(name);
|
|
56440
|
+
}
|
|
56428
56441
|
function hasBindableName(node) {
|
|
56429
56442
|
return !hasDynamicName(node) || hasLateBindableName(node);
|
|
56430
56443
|
}
|
|
@@ -56478,6 +56491,24 @@ function createTypeChecker(host) {
|
|
|
56478
56491
|
}
|
|
56479
56492
|
return links.resolvedSymbol;
|
|
56480
56493
|
}
|
|
56494
|
+
function lateBindIndexSignature(parent, earlySymbols, lateSymbols, decl) {
|
|
56495
|
+
let indexSymbol = lateSymbols.get("__index" /* Index */);
|
|
56496
|
+
if (!indexSymbol) {
|
|
56497
|
+
const early = earlySymbols == null ? void 0 : earlySymbols.get("__index" /* Index */);
|
|
56498
|
+
if (!early) {
|
|
56499
|
+
indexSymbol = createSymbol(0 /* None */, "__index" /* Index */, 4096 /* Late */);
|
|
56500
|
+
} else {
|
|
56501
|
+
indexSymbol = cloneSymbol(early);
|
|
56502
|
+
indexSymbol.links.checkFlags |= 4096 /* Late */;
|
|
56503
|
+
}
|
|
56504
|
+
lateSymbols.set("__index" /* Index */, indexSymbol);
|
|
56505
|
+
}
|
|
56506
|
+
if (!indexSymbol.declarations) {
|
|
56507
|
+
indexSymbol.declarations = [decl];
|
|
56508
|
+
} else if (!decl.symbol.isReplaceableByMethod) {
|
|
56509
|
+
indexSymbol.declarations.push(decl);
|
|
56510
|
+
}
|
|
56511
|
+
}
|
|
56481
56512
|
function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
|
|
56482
56513
|
const links = getSymbolLinks(symbol);
|
|
56483
56514
|
if (!links[resolutionKind]) {
|
|
@@ -56492,6 +56523,8 @@ function createTypeChecker(host) {
|
|
|
56492
56523
|
if (isStatic2 === hasStaticModifier(member)) {
|
|
56493
56524
|
if (hasLateBindableName(member)) {
|
|
56494
56525
|
lateBindMember(symbol, earlySymbols, lateSymbols, member);
|
|
56526
|
+
} else if (hasLateBindableIndexSignature(member)) {
|
|
56527
|
+
lateBindIndexSignature(symbol, earlySymbols, lateSymbols, member);
|
|
56495
56528
|
}
|
|
56496
56529
|
}
|
|
56497
56530
|
}
|
|
@@ -57136,7 +57169,7 @@ function createTypeChecker(host) {
|
|
|
57136
57169
|
}
|
|
57137
57170
|
const indexSymbol = getIndexSymbolFromSymbolTable(members);
|
|
57138
57171
|
if (indexSymbol) {
|
|
57139
|
-
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
|
|
57172
|
+
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol, arrayFrom(members.values()));
|
|
57140
57173
|
} else {
|
|
57141
57174
|
if (baseConstructorIndexInfo) {
|
|
57142
57175
|
indexInfos = append(indexInfos, baseConstructorIndexInfo);
|
|
@@ -58755,7 +58788,7 @@ function createTypeChecker(host) {
|
|
|
58755
58788
|
return signature.isolatedSignatureType;
|
|
58756
58789
|
}
|
|
58757
58790
|
function getIndexSymbol(symbol) {
|
|
58758
|
-
return symbol.members ? getIndexSymbolFromSymbolTable(symbol
|
|
58791
|
+
return symbol.members ? getIndexSymbolFromSymbolTable(getMembersOfSymbol(symbol)) : void 0;
|
|
58759
58792
|
}
|
|
58760
58793
|
function getIndexSymbolFromSymbolTable(symbolTable) {
|
|
58761
58794
|
return symbolTable.get("__index" /* Index */);
|
|
@@ -58765,23 +58798,61 @@ function createTypeChecker(host) {
|
|
|
58765
58798
|
}
|
|
58766
58799
|
function getIndexInfosOfSymbol(symbol) {
|
|
58767
58800
|
const indexSymbol = getIndexSymbol(symbol);
|
|
58768
|
-
return indexSymbol ? getIndexInfosOfIndexSymbol(indexSymbol) : emptyArray;
|
|
58801
|
+
return indexSymbol ? getIndexInfosOfIndexSymbol(indexSymbol, arrayFrom(getMembersOfSymbol(symbol).values())) : emptyArray;
|
|
58769
58802
|
}
|
|
58770
|
-
function getIndexInfosOfIndexSymbol(indexSymbol) {
|
|
58803
|
+
function getIndexInfosOfIndexSymbol(indexSymbol, siblingSymbols = indexSymbol.parent ? arrayFrom(getMembersOfSymbol(indexSymbol.parent).values()) : void 0) {
|
|
58771
58804
|
if (indexSymbol.declarations) {
|
|
58772
58805
|
const indexInfos = [];
|
|
58806
|
+
let hasComputedNumberProperty = false;
|
|
58807
|
+
let readonlyComputedNumberProperty = true;
|
|
58808
|
+
let hasComputedSymbolProperty = false;
|
|
58809
|
+
let readonlyComputedSymbolProperty = true;
|
|
58810
|
+
let hasComputedStringProperty = false;
|
|
58811
|
+
let readonlyComputedStringProperty = true;
|
|
58812
|
+
const computedPropertySymbols = [];
|
|
58773
58813
|
for (const declaration of indexSymbol.declarations) {
|
|
58774
|
-
if (declaration
|
|
58775
|
-
|
|
58776
|
-
|
|
58777
|
-
|
|
58778
|
-
|
|
58779
|
-
|
|
58814
|
+
if (isIndexSignatureDeclaration(declaration)) {
|
|
58815
|
+
if (declaration.parameters.length === 1) {
|
|
58816
|
+
const parameter = declaration.parameters[0];
|
|
58817
|
+
if (parameter.type) {
|
|
58818
|
+
forEachType(getTypeFromTypeNode(parameter.type), (keyType) => {
|
|
58819
|
+
if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos, keyType)) {
|
|
58820
|
+
indexInfos.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, hasEffectiveModifier(declaration, 8 /* Readonly */), declaration));
|
|
58821
|
+
}
|
|
58822
|
+
});
|
|
58823
|
+
}
|
|
58824
|
+
}
|
|
58825
|
+
} else if (hasLateBindableIndexSignature(declaration)) {
|
|
58826
|
+
const declName = isBinaryExpression(declaration) ? declaration.left : declaration.name;
|
|
58827
|
+
const keyType = isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName);
|
|
58828
|
+
if (findIndexInfo(indexInfos, keyType)) {
|
|
58829
|
+
continue;
|
|
58830
|
+
}
|
|
58831
|
+
if (isTypeAssignableTo(keyType, stringNumberSymbolType)) {
|
|
58832
|
+
if (isTypeAssignableTo(keyType, numberType)) {
|
|
58833
|
+
hasComputedNumberProperty = true;
|
|
58834
|
+
if (!hasEffectiveReadonlyModifier(declaration)) {
|
|
58835
|
+
readonlyComputedNumberProperty = false;
|
|
58780
58836
|
}
|
|
58781
|
-
})
|
|
58837
|
+
} else if (isTypeAssignableTo(keyType, esSymbolType)) {
|
|
58838
|
+
hasComputedSymbolProperty = true;
|
|
58839
|
+
if (!hasEffectiveReadonlyModifier(declaration)) {
|
|
58840
|
+
readonlyComputedSymbolProperty = false;
|
|
58841
|
+
}
|
|
58842
|
+
} else {
|
|
58843
|
+
hasComputedStringProperty = true;
|
|
58844
|
+
if (!hasEffectiveReadonlyModifier(declaration)) {
|
|
58845
|
+
readonlyComputedStringProperty = false;
|
|
58846
|
+
}
|
|
58847
|
+
}
|
|
58848
|
+
computedPropertySymbols.push(declaration.symbol);
|
|
58782
58849
|
}
|
|
58783
58850
|
}
|
|
58784
58851
|
}
|
|
58852
|
+
const allPropertySymbols = concatenate(computedPropertySymbols, filter(siblingSymbols, (s) => s !== indexSymbol));
|
|
58853
|
+
if (hasComputedStringProperty && !findIndexInfo(indexInfos, stringType)) indexInfos.push(getObjectLiteralIndexInfo(readonlyComputedStringProperty, 0, allPropertySymbols, stringType));
|
|
58854
|
+
if (hasComputedNumberProperty && !findIndexInfo(indexInfos, numberType)) indexInfos.push(getObjectLiteralIndexInfo(readonlyComputedNumberProperty, 0, allPropertySymbols, numberType));
|
|
58855
|
+
if (hasComputedSymbolProperty && !findIndexInfo(indexInfos, esSymbolType)) indexInfos.push(getObjectLiteralIndexInfo(readonlyComputedSymbolProperty, 0, allPropertySymbols, esSymbolType));
|
|
58785
58856
|
return indexInfos;
|
|
58786
58857
|
}
|
|
58787
58858
|
return emptyArray;
|
|
@@ -72665,7 +72736,7 @@ function createTypeChecker(host) {
|
|
|
72665
72736
|
const firstDecl = (_a = symbol.declarations) == null ? void 0 : _a[0];
|
|
72666
72737
|
return isKnownSymbol(symbol) || firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name) && isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */);
|
|
72667
72738
|
}
|
|
72668
|
-
function getObjectLiteralIndexInfo(
|
|
72739
|
+
function getObjectLiteralIndexInfo(isReadonly, offset, properties, keyType) {
|
|
72669
72740
|
const propTypes = [];
|
|
72670
72741
|
for (let i = offset; i < properties.length; i++) {
|
|
72671
72742
|
const prop = properties[i];
|
|
@@ -72674,7 +72745,7 @@ function createTypeChecker(host) {
|
|
|
72674
72745
|
}
|
|
72675
72746
|
}
|
|
72676
72747
|
const unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType;
|
|
72677
|
-
return createIndexInfo(keyType, unionType,
|
|
72748
|
+
return createIndexInfo(keyType, unionType, isReadonly);
|
|
72678
72749
|
}
|
|
72679
72750
|
function getImmediateAliasedSymbol(symbol) {
|
|
72680
72751
|
Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
|
|
@@ -72837,9 +72908,10 @@ function createTypeChecker(host) {
|
|
|
72837
72908
|
return createObjectLiteralType();
|
|
72838
72909
|
function createObjectLiteralType() {
|
|
72839
72910
|
const indexInfos = [];
|
|
72840
|
-
|
|
72841
|
-
if (
|
|
72842
|
-
if (
|
|
72911
|
+
const isReadonly = isConstContext(node);
|
|
72912
|
+
if (hasComputedStringProperty) indexInfos.push(getObjectLiteralIndexInfo(isReadonly, offset, propertiesArray, stringType));
|
|
72913
|
+
if (hasComputedNumberProperty) indexInfos.push(getObjectLiteralIndexInfo(isReadonly, offset, propertiesArray, numberType));
|
|
72914
|
+
if (hasComputedSymbolProperty) indexInfos.push(getObjectLiteralIndexInfo(isReadonly, offset, propertiesArray, esSymbolType));
|
|
72843
72915
|
const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, indexInfos);
|
|
72844
72916
|
result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */;
|
|
72845
72917
|
if (isJSObjectLiteral) {
|
|
@@ -76484,9 +76556,17 @@ function createTypeChecker(host) {
|
|
|
76484
76556
|
if (exprType === silentNeverType || isErrorType(exprType) || !some(typeArguments)) {
|
|
76485
76557
|
return exprType;
|
|
76486
76558
|
}
|
|
76559
|
+
const links = getNodeLinks(node);
|
|
76560
|
+
if (!links.instantiationExpressionTypes) {
|
|
76561
|
+
links.instantiationExpressionTypes = /* @__PURE__ */ new Map();
|
|
76562
|
+
}
|
|
76563
|
+
if (links.instantiationExpressionTypes.has(exprType.id)) {
|
|
76564
|
+
return links.instantiationExpressionTypes.get(exprType.id);
|
|
76565
|
+
}
|
|
76487
76566
|
let hasSomeApplicableSignature = false;
|
|
76488
76567
|
let nonApplicableType;
|
|
76489
76568
|
const result = getInstantiatedType(exprType);
|
|
76569
|
+
links.instantiationExpressionTypes.set(exprType.id, result);
|
|
76490
76570
|
const errorType2 = hasSomeApplicableSignature ? nonApplicableType : exprType;
|
|
76491
76571
|
if (errorType2) {
|
|
76492
76572
|
diagnostics.add(createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable, typeToString(errorType2)));
|
|
@@ -79955,15 +80035,17 @@ function createTypeChecker(host) {
|
|
|
79955
80035
|
if (indexSymbol == null ? void 0 : indexSymbol.declarations) {
|
|
79956
80036
|
const indexSignatureMap = /* @__PURE__ */ new Map();
|
|
79957
80037
|
for (const declaration of indexSymbol.declarations) {
|
|
79958
|
-
if (declaration
|
|
79959
|
-
|
|
79960
|
-
|
|
79961
|
-
|
|
79962
|
-
entry
|
|
79963
|
-
|
|
79964
|
-
|
|
79965
|
-
|
|
79966
|
-
|
|
80038
|
+
if (isIndexSignatureDeclaration(declaration)) {
|
|
80039
|
+
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
|
|
80040
|
+
forEachType(getTypeFromTypeNode(declaration.parameters[0].type), (type) => {
|
|
80041
|
+
const entry = indexSignatureMap.get(getTypeId(type));
|
|
80042
|
+
if (entry) {
|
|
80043
|
+
entry.declarations.push(declaration);
|
|
80044
|
+
} else {
|
|
80045
|
+
indexSignatureMap.set(getTypeId(type), { type, declarations: [declaration] });
|
|
80046
|
+
}
|
|
80047
|
+
});
|
|
80048
|
+
}
|
|
79967
80049
|
}
|
|
79968
80050
|
}
|
|
79969
80051
|
indexSignatureMap.forEach((entry) => {
|
|
@@ -86871,7 +86953,29 @@ function createTypeChecker(host) {
|
|
|
86871
86953
|
return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, internalFlags, tracker);
|
|
86872
86954
|
},
|
|
86873
86955
|
isImportRequiredByAugmentation,
|
|
86874
|
-
isDefinitelyReferenceToGlobalSymbolObject
|
|
86956
|
+
isDefinitelyReferenceToGlobalSymbolObject,
|
|
86957
|
+
createLateBoundIndexSignatures: (cls, enclosing, flags, internalFlags, tracker) => {
|
|
86958
|
+
const sym = cls.symbol;
|
|
86959
|
+
const staticInfos = getIndexInfosOfType(getTypeOfSymbol(sym));
|
|
86960
|
+
const instanceIndexSymbol = getIndexSymbol(sym);
|
|
86961
|
+
const instanceInfos = instanceIndexSymbol && getIndexInfosOfIndexSymbol(instanceIndexSymbol, arrayFrom(getMembersOfSymbol(sym).values()));
|
|
86962
|
+
let result;
|
|
86963
|
+
for (const infoList of [staticInfos, instanceInfos]) {
|
|
86964
|
+
if (!length(infoList)) continue;
|
|
86965
|
+
result || (result = []);
|
|
86966
|
+
for (const info of infoList) {
|
|
86967
|
+
if (info.declaration) continue;
|
|
86968
|
+
const node = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, enclosing, flags, internalFlags, tracker);
|
|
86969
|
+
if (node && infoList === staticInfos) {
|
|
86970
|
+
(node.modifiers || (node.modifiers = factory.createNodeArray())).unshift(factory.createModifier(126 /* StaticKeyword */));
|
|
86971
|
+
}
|
|
86972
|
+
if (node) {
|
|
86973
|
+
result.push(node);
|
|
86974
|
+
}
|
|
86975
|
+
}
|
|
86976
|
+
}
|
|
86977
|
+
return result;
|
|
86978
|
+
}
|
|
86875
86979
|
};
|
|
86876
86980
|
function isImportRequiredByAugmentation(node) {
|
|
86877
86981
|
const file = getSourceFileOfNode(node);
|
|
@@ -113356,7 +113460,8 @@ function transformDeclarations(context) {
|
|
|
113356
113460
|
void 0
|
|
113357
113461
|
)
|
|
113358
113462
|
] : void 0;
|
|
113359
|
-
const
|
|
113463
|
+
const lateIndexes = resolver.createLateBoundIndexSignatures(input, enclosingDeclaration, declarationEmitNodeBuilderFlags, declarationEmitInternalNodeBuilderFlags, symbolTracker);
|
|
113464
|
+
const memberNodes = concatenate(concatenate(concatenate(privateIdentifier, lateIndexes), parameterProperties), visitNodes2(input.members, visitDeclarationSubtree, isClassElement));
|
|
113360
113465
|
const members = factory2.createNodeArray(memberNodes);
|
|
113361
113466
|
const extendsClause = getEffectiveBaseTypeNode(input);
|
|
113362
113467
|
if (extendsClause && !isEntityNameExpression(extendsClause.expression) && extendsClause.expression.kind !== 106 /* NullKeyword */) {
|
|
@@ -114661,7 +114766,8 @@ var notImplementedResolver = {
|
|
|
114661
114766
|
isBindingCapturedByNode: notImplemented,
|
|
114662
114767
|
getDeclarationStatementsForSourceFile: notImplemented,
|
|
114663
114768
|
isImportRequiredByAugmentation: notImplemented,
|
|
114664
|
-
isDefinitelyReferenceToGlobalSymbolObject: notImplemented
|
|
114769
|
+
isDefinitelyReferenceToGlobalSymbolObject: notImplemented,
|
|
114770
|
+
createLateBoundIndexSignatures: notImplemented
|
|
114665
114771
|
};
|
|
114666
114772
|
var createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
|
|
114667
114773
|
var createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));
|
package/lib/typescript.d.ts
CHANGED
|
@@ -6140,7 +6140,7 @@ declare namespace ts {
|
|
|
6140
6140
|
getPrivateIdentifierPropertyOfType(leftType: Type, name: string, location: Node): Symbol | undefined;
|
|
6141
6141
|
getIndexInfoOfType(type: Type, kind: IndexKind): IndexInfo | undefined;
|
|
6142
6142
|
getIndexInfosOfType(type: Type): readonly IndexInfo[];
|
|
6143
|
-
getIndexInfosOfIndexSymbol: (indexSymbol: Symbol) => IndexInfo[];
|
|
6143
|
+
getIndexInfosOfIndexSymbol: (indexSymbol: Symbol, siblingSymbols?: Symbol[] | undefined) => IndexInfo[];
|
|
6144
6144
|
getSignaturesOfType(type: Type, kind: SignatureKind): readonly Signature[];
|
|
6145
6145
|
getIndexTypeOfType(type: Type, kind: IndexKind): Type | undefined;
|
|
6146
6146
|
getBaseTypes(type: InterfaceType): BaseType[];
|
package/lib/typescript.js
CHANGED
|
@@ -2270,7 +2270,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2270
2270
|
|
|
2271
2271
|
// src/compiler/corePublic.ts
|
|
2272
2272
|
var versionMajorMinor = "5.7";
|
|
2273
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2273
|
+
var version = `${versionMajorMinor}.0-dev.20240924`;
|
|
2274
2274
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2275
2275
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2276
2276
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -61008,11 +61008,20 @@ function createTypeChecker(host) {
|
|
|
61008
61008
|
return type;
|
|
61009
61009
|
}
|
|
61010
61010
|
function isLateBindableName(node) {
|
|
61011
|
+
return isLateBindableAST(node) && isTypeUsableAsPropertyName(isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(node.argumentExpression));
|
|
61012
|
+
}
|
|
61013
|
+
function isLateBindableIndexSignature(node) {
|
|
61014
|
+
return isLateBindableAST(node) && isTypeUsableAsIndexSignature(isComputedPropertyName(node) ? checkComputedPropertyName(node) : checkExpressionCached(node.argumentExpression));
|
|
61015
|
+
}
|
|
61016
|
+
function isLateBindableAST(node) {
|
|
61011
61017
|
if (!isComputedPropertyName(node) && !isElementAccessExpression(node)) {
|
|
61012
61018
|
return false;
|
|
61013
61019
|
}
|
|
61014
61020
|
const expr = isComputedPropertyName(node) ? node.expression : node.argumentExpression;
|
|
61015
|
-
return isEntityNameExpression(expr)
|
|
61021
|
+
return isEntityNameExpression(expr);
|
|
61022
|
+
}
|
|
61023
|
+
function isTypeUsableAsIndexSignature(type) {
|
|
61024
|
+
return isTypeAssignableTo(type, stringNumberSymbolType);
|
|
61016
61025
|
}
|
|
61017
61026
|
function isLateBoundName(name) {
|
|
61018
61027
|
return name.charCodeAt(0) === 95 /* _ */ && name.charCodeAt(1) === 95 /* _ */ && name.charCodeAt(2) === 64 /* at */;
|
|
@@ -61021,6 +61030,10 @@ function createTypeChecker(host) {
|
|
|
61021
61030
|
const name = getNameOfDeclaration(node);
|
|
61022
61031
|
return !!name && isLateBindableName(name);
|
|
61023
61032
|
}
|
|
61033
|
+
function hasLateBindableIndexSignature(node) {
|
|
61034
|
+
const name = getNameOfDeclaration(node);
|
|
61035
|
+
return !!name && isLateBindableIndexSignature(name);
|
|
61036
|
+
}
|
|
61024
61037
|
function hasBindableName(node) {
|
|
61025
61038
|
return !hasDynamicName(node) || hasLateBindableName(node);
|
|
61026
61039
|
}
|
|
@@ -61074,6 +61087,24 @@ function createTypeChecker(host) {
|
|
|
61074
61087
|
}
|
|
61075
61088
|
return links.resolvedSymbol;
|
|
61076
61089
|
}
|
|
61090
|
+
function lateBindIndexSignature(parent2, earlySymbols, lateSymbols, decl) {
|
|
61091
|
+
let indexSymbol = lateSymbols.get("__index" /* Index */);
|
|
61092
|
+
if (!indexSymbol) {
|
|
61093
|
+
const early = earlySymbols == null ? void 0 : earlySymbols.get("__index" /* Index */);
|
|
61094
|
+
if (!early) {
|
|
61095
|
+
indexSymbol = createSymbol(0 /* None */, "__index" /* Index */, 4096 /* Late */);
|
|
61096
|
+
} else {
|
|
61097
|
+
indexSymbol = cloneSymbol(early);
|
|
61098
|
+
indexSymbol.links.checkFlags |= 4096 /* Late */;
|
|
61099
|
+
}
|
|
61100
|
+
lateSymbols.set("__index" /* Index */, indexSymbol);
|
|
61101
|
+
}
|
|
61102
|
+
if (!indexSymbol.declarations) {
|
|
61103
|
+
indexSymbol.declarations = [decl];
|
|
61104
|
+
} else if (!decl.symbol.isReplaceableByMethod) {
|
|
61105
|
+
indexSymbol.declarations.push(decl);
|
|
61106
|
+
}
|
|
61107
|
+
}
|
|
61077
61108
|
function getResolvedMembersOrExportsOfSymbol(symbol, resolutionKind) {
|
|
61078
61109
|
const links = getSymbolLinks(symbol);
|
|
61079
61110
|
if (!links[resolutionKind]) {
|
|
@@ -61088,6 +61119,8 @@ function createTypeChecker(host) {
|
|
|
61088
61119
|
if (isStatic2 === hasStaticModifier(member)) {
|
|
61089
61120
|
if (hasLateBindableName(member)) {
|
|
61090
61121
|
lateBindMember(symbol, earlySymbols, lateSymbols, member);
|
|
61122
|
+
} else if (hasLateBindableIndexSignature(member)) {
|
|
61123
|
+
lateBindIndexSignature(symbol, earlySymbols, lateSymbols, member);
|
|
61091
61124
|
}
|
|
61092
61125
|
}
|
|
61093
61126
|
}
|
|
@@ -61732,7 +61765,7 @@ function createTypeChecker(host) {
|
|
|
61732
61765
|
}
|
|
61733
61766
|
const indexSymbol = getIndexSymbolFromSymbolTable(members);
|
|
61734
61767
|
if (indexSymbol) {
|
|
61735
|
-
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol);
|
|
61768
|
+
indexInfos = getIndexInfosOfIndexSymbol(indexSymbol, arrayFrom(members.values()));
|
|
61736
61769
|
} else {
|
|
61737
61770
|
if (baseConstructorIndexInfo) {
|
|
61738
61771
|
indexInfos = append(indexInfos, baseConstructorIndexInfo);
|
|
@@ -63351,7 +63384,7 @@ function createTypeChecker(host) {
|
|
|
63351
63384
|
return signature.isolatedSignatureType;
|
|
63352
63385
|
}
|
|
63353
63386
|
function getIndexSymbol(symbol) {
|
|
63354
|
-
return symbol.members ? getIndexSymbolFromSymbolTable(symbol
|
|
63387
|
+
return symbol.members ? getIndexSymbolFromSymbolTable(getMembersOfSymbol(symbol)) : void 0;
|
|
63355
63388
|
}
|
|
63356
63389
|
function getIndexSymbolFromSymbolTable(symbolTable) {
|
|
63357
63390
|
return symbolTable.get("__index" /* Index */);
|
|
@@ -63361,23 +63394,61 @@ function createTypeChecker(host) {
|
|
|
63361
63394
|
}
|
|
63362
63395
|
function getIndexInfosOfSymbol(symbol) {
|
|
63363
63396
|
const indexSymbol = getIndexSymbol(symbol);
|
|
63364
|
-
return indexSymbol ? getIndexInfosOfIndexSymbol(indexSymbol) : emptyArray;
|
|
63397
|
+
return indexSymbol ? getIndexInfosOfIndexSymbol(indexSymbol, arrayFrom(getMembersOfSymbol(symbol).values())) : emptyArray;
|
|
63365
63398
|
}
|
|
63366
|
-
function getIndexInfosOfIndexSymbol(indexSymbol) {
|
|
63399
|
+
function getIndexInfosOfIndexSymbol(indexSymbol, siblingSymbols = indexSymbol.parent ? arrayFrom(getMembersOfSymbol(indexSymbol.parent).values()) : void 0) {
|
|
63367
63400
|
if (indexSymbol.declarations) {
|
|
63368
63401
|
const indexInfos = [];
|
|
63402
|
+
let hasComputedNumberProperty = false;
|
|
63403
|
+
let readonlyComputedNumberProperty = true;
|
|
63404
|
+
let hasComputedSymbolProperty = false;
|
|
63405
|
+
let readonlyComputedSymbolProperty = true;
|
|
63406
|
+
let hasComputedStringProperty = false;
|
|
63407
|
+
let readonlyComputedStringProperty = true;
|
|
63408
|
+
const computedPropertySymbols = [];
|
|
63369
63409
|
for (const declaration of indexSymbol.declarations) {
|
|
63370
|
-
if (declaration
|
|
63371
|
-
|
|
63372
|
-
|
|
63373
|
-
|
|
63374
|
-
|
|
63375
|
-
|
|
63410
|
+
if (isIndexSignatureDeclaration(declaration)) {
|
|
63411
|
+
if (declaration.parameters.length === 1) {
|
|
63412
|
+
const parameter = declaration.parameters[0];
|
|
63413
|
+
if (parameter.type) {
|
|
63414
|
+
forEachType(getTypeFromTypeNode(parameter.type), (keyType) => {
|
|
63415
|
+
if (isValidIndexKeyType(keyType) && !findIndexInfo(indexInfos, keyType)) {
|
|
63416
|
+
indexInfos.push(createIndexInfo(keyType, declaration.type ? getTypeFromTypeNode(declaration.type) : anyType, hasEffectiveModifier(declaration, 8 /* Readonly */), declaration));
|
|
63417
|
+
}
|
|
63418
|
+
});
|
|
63419
|
+
}
|
|
63420
|
+
}
|
|
63421
|
+
} else if (hasLateBindableIndexSignature(declaration)) {
|
|
63422
|
+
const declName = isBinaryExpression(declaration) ? declaration.left : declaration.name;
|
|
63423
|
+
const keyType = isElementAccessExpression(declName) ? checkExpressionCached(declName.argumentExpression) : checkComputedPropertyName(declName);
|
|
63424
|
+
if (findIndexInfo(indexInfos, keyType)) {
|
|
63425
|
+
continue;
|
|
63426
|
+
}
|
|
63427
|
+
if (isTypeAssignableTo(keyType, stringNumberSymbolType)) {
|
|
63428
|
+
if (isTypeAssignableTo(keyType, numberType)) {
|
|
63429
|
+
hasComputedNumberProperty = true;
|
|
63430
|
+
if (!hasEffectiveReadonlyModifier(declaration)) {
|
|
63431
|
+
readonlyComputedNumberProperty = false;
|
|
63376
63432
|
}
|
|
63377
|
-
})
|
|
63433
|
+
} else if (isTypeAssignableTo(keyType, esSymbolType)) {
|
|
63434
|
+
hasComputedSymbolProperty = true;
|
|
63435
|
+
if (!hasEffectiveReadonlyModifier(declaration)) {
|
|
63436
|
+
readonlyComputedSymbolProperty = false;
|
|
63437
|
+
}
|
|
63438
|
+
} else {
|
|
63439
|
+
hasComputedStringProperty = true;
|
|
63440
|
+
if (!hasEffectiveReadonlyModifier(declaration)) {
|
|
63441
|
+
readonlyComputedStringProperty = false;
|
|
63442
|
+
}
|
|
63443
|
+
}
|
|
63444
|
+
computedPropertySymbols.push(declaration.symbol);
|
|
63378
63445
|
}
|
|
63379
63446
|
}
|
|
63380
63447
|
}
|
|
63448
|
+
const allPropertySymbols = concatenate(computedPropertySymbols, filter(siblingSymbols, (s) => s !== indexSymbol));
|
|
63449
|
+
if (hasComputedStringProperty && !findIndexInfo(indexInfos, stringType)) indexInfos.push(getObjectLiteralIndexInfo(readonlyComputedStringProperty, 0, allPropertySymbols, stringType));
|
|
63450
|
+
if (hasComputedNumberProperty && !findIndexInfo(indexInfos, numberType)) indexInfos.push(getObjectLiteralIndexInfo(readonlyComputedNumberProperty, 0, allPropertySymbols, numberType));
|
|
63451
|
+
if (hasComputedSymbolProperty && !findIndexInfo(indexInfos, esSymbolType)) indexInfos.push(getObjectLiteralIndexInfo(readonlyComputedSymbolProperty, 0, allPropertySymbols, esSymbolType));
|
|
63381
63452
|
return indexInfos;
|
|
63382
63453
|
}
|
|
63383
63454
|
return emptyArray;
|
|
@@ -77261,7 +77332,7 @@ function createTypeChecker(host) {
|
|
|
77261
77332
|
const firstDecl = (_a = symbol.declarations) == null ? void 0 : _a[0];
|
|
77262
77333
|
return isKnownSymbol(symbol) || firstDecl && isNamedDeclaration(firstDecl) && isComputedPropertyName(firstDecl.name) && isTypeAssignableToKind(checkComputedPropertyName(firstDecl.name), 4096 /* ESSymbol */);
|
|
77263
77334
|
}
|
|
77264
|
-
function getObjectLiteralIndexInfo(
|
|
77335
|
+
function getObjectLiteralIndexInfo(isReadonly, offset, properties, keyType) {
|
|
77265
77336
|
const propTypes = [];
|
|
77266
77337
|
for (let i = offset; i < properties.length; i++) {
|
|
77267
77338
|
const prop = properties[i];
|
|
@@ -77270,7 +77341,7 @@ function createTypeChecker(host) {
|
|
|
77270
77341
|
}
|
|
77271
77342
|
}
|
|
77272
77343
|
const unionType = propTypes.length ? getUnionType(propTypes, 2 /* Subtype */) : undefinedType;
|
|
77273
|
-
return createIndexInfo(keyType, unionType,
|
|
77344
|
+
return createIndexInfo(keyType, unionType, isReadonly);
|
|
77274
77345
|
}
|
|
77275
77346
|
function getImmediateAliasedSymbol(symbol) {
|
|
77276
77347
|
Debug.assert((symbol.flags & 2097152 /* Alias */) !== 0, "Should only get Alias here.");
|
|
@@ -77433,9 +77504,10 @@ function createTypeChecker(host) {
|
|
|
77433
77504
|
return createObjectLiteralType();
|
|
77434
77505
|
function createObjectLiteralType() {
|
|
77435
77506
|
const indexInfos = [];
|
|
77436
|
-
|
|
77437
|
-
if (
|
|
77438
|
-
if (
|
|
77507
|
+
const isReadonly = isConstContext(node);
|
|
77508
|
+
if (hasComputedStringProperty) indexInfos.push(getObjectLiteralIndexInfo(isReadonly, offset, propertiesArray, stringType));
|
|
77509
|
+
if (hasComputedNumberProperty) indexInfos.push(getObjectLiteralIndexInfo(isReadonly, offset, propertiesArray, numberType));
|
|
77510
|
+
if (hasComputedSymbolProperty) indexInfos.push(getObjectLiteralIndexInfo(isReadonly, offset, propertiesArray, esSymbolType));
|
|
77439
77511
|
const result = createAnonymousType(node.symbol, propertiesTable, emptyArray, emptyArray, indexInfos);
|
|
77440
77512
|
result.objectFlags |= objectFlags | 128 /* ObjectLiteral */ | 131072 /* ContainsObjectOrArrayLiteral */;
|
|
77441
77513
|
if (isJSObjectLiteral) {
|
|
@@ -81080,9 +81152,17 @@ function createTypeChecker(host) {
|
|
|
81080
81152
|
if (exprType === silentNeverType || isErrorType(exprType) || !some(typeArguments)) {
|
|
81081
81153
|
return exprType;
|
|
81082
81154
|
}
|
|
81155
|
+
const links = getNodeLinks(node);
|
|
81156
|
+
if (!links.instantiationExpressionTypes) {
|
|
81157
|
+
links.instantiationExpressionTypes = /* @__PURE__ */ new Map();
|
|
81158
|
+
}
|
|
81159
|
+
if (links.instantiationExpressionTypes.has(exprType.id)) {
|
|
81160
|
+
return links.instantiationExpressionTypes.get(exprType.id);
|
|
81161
|
+
}
|
|
81083
81162
|
let hasSomeApplicableSignature = false;
|
|
81084
81163
|
let nonApplicableType;
|
|
81085
81164
|
const result = getInstantiatedType(exprType);
|
|
81165
|
+
links.instantiationExpressionTypes.set(exprType.id, result);
|
|
81086
81166
|
const errorType2 = hasSomeApplicableSignature ? nonApplicableType : exprType;
|
|
81087
81167
|
if (errorType2) {
|
|
81088
81168
|
diagnostics.add(createDiagnosticForNodeArray(getSourceFileOfNode(node), typeArguments, Diagnostics.Type_0_has_no_signatures_for_which_the_type_argument_list_is_applicable, typeToString(errorType2)));
|
|
@@ -84551,15 +84631,17 @@ function createTypeChecker(host) {
|
|
|
84551
84631
|
if (indexSymbol == null ? void 0 : indexSymbol.declarations) {
|
|
84552
84632
|
const indexSignatureMap = /* @__PURE__ */ new Map();
|
|
84553
84633
|
for (const declaration of indexSymbol.declarations) {
|
|
84554
|
-
if (declaration
|
|
84555
|
-
|
|
84556
|
-
|
|
84557
|
-
|
|
84558
|
-
entry
|
|
84559
|
-
|
|
84560
|
-
|
|
84561
|
-
|
|
84562
|
-
|
|
84634
|
+
if (isIndexSignatureDeclaration(declaration)) {
|
|
84635
|
+
if (declaration.parameters.length === 1 && declaration.parameters[0].type) {
|
|
84636
|
+
forEachType(getTypeFromTypeNode(declaration.parameters[0].type), (type) => {
|
|
84637
|
+
const entry = indexSignatureMap.get(getTypeId(type));
|
|
84638
|
+
if (entry) {
|
|
84639
|
+
entry.declarations.push(declaration);
|
|
84640
|
+
} else {
|
|
84641
|
+
indexSignatureMap.set(getTypeId(type), { type, declarations: [declaration] });
|
|
84642
|
+
}
|
|
84643
|
+
});
|
|
84644
|
+
}
|
|
84563
84645
|
}
|
|
84564
84646
|
}
|
|
84565
84647
|
indexSignatureMap.forEach((entry) => {
|
|
@@ -91467,7 +91549,29 @@ function createTypeChecker(host) {
|
|
|
91467
91549
|
return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, internalFlags, tracker);
|
|
91468
91550
|
},
|
|
91469
91551
|
isImportRequiredByAugmentation,
|
|
91470
|
-
isDefinitelyReferenceToGlobalSymbolObject
|
|
91552
|
+
isDefinitelyReferenceToGlobalSymbolObject,
|
|
91553
|
+
createLateBoundIndexSignatures: (cls, enclosing, flags, internalFlags, tracker) => {
|
|
91554
|
+
const sym = cls.symbol;
|
|
91555
|
+
const staticInfos = getIndexInfosOfType(getTypeOfSymbol(sym));
|
|
91556
|
+
const instanceIndexSymbol = getIndexSymbol(sym);
|
|
91557
|
+
const instanceInfos = instanceIndexSymbol && getIndexInfosOfIndexSymbol(instanceIndexSymbol, arrayFrom(getMembersOfSymbol(sym).values()));
|
|
91558
|
+
let result;
|
|
91559
|
+
for (const infoList of [staticInfos, instanceInfos]) {
|
|
91560
|
+
if (!length(infoList)) continue;
|
|
91561
|
+
result || (result = []);
|
|
91562
|
+
for (const info of infoList) {
|
|
91563
|
+
if (info.declaration) continue;
|
|
91564
|
+
const node = nodeBuilder.indexInfoToIndexSignatureDeclaration(info, enclosing, flags, internalFlags, tracker);
|
|
91565
|
+
if (node && infoList === staticInfos) {
|
|
91566
|
+
(node.modifiers || (node.modifiers = factory.createNodeArray())).unshift(factory.createModifier(126 /* StaticKeyword */));
|
|
91567
|
+
}
|
|
91568
|
+
if (node) {
|
|
91569
|
+
result.push(node);
|
|
91570
|
+
}
|
|
91571
|
+
}
|
|
91572
|
+
}
|
|
91573
|
+
return result;
|
|
91574
|
+
}
|
|
91471
91575
|
};
|
|
91472
91576
|
function isImportRequiredByAugmentation(node) {
|
|
91473
91577
|
const file = getSourceFileOfNode(node);
|
|
@@ -118134,7 +118238,8 @@ function transformDeclarations(context) {
|
|
|
118134
118238
|
void 0
|
|
118135
118239
|
)
|
|
118136
118240
|
] : void 0;
|
|
118137
|
-
const
|
|
118241
|
+
const lateIndexes = resolver.createLateBoundIndexSignatures(input, enclosingDeclaration, declarationEmitNodeBuilderFlags, declarationEmitInternalNodeBuilderFlags, symbolTracker);
|
|
118242
|
+
const memberNodes = concatenate(concatenate(concatenate(privateIdentifier, lateIndexes), parameterProperties), visitNodes2(input.members, visitDeclarationSubtree, isClassElement));
|
|
118138
118243
|
const members = factory2.createNodeArray(memberNodes);
|
|
118139
118244
|
const extendsClause = getEffectiveBaseTypeNode(input);
|
|
118140
118245
|
if (extendsClause && !isEntityNameExpression(extendsClause.expression) && extendsClause.expression.kind !== 106 /* NullKeyword */) {
|
|
@@ -119450,7 +119555,8 @@ var notImplementedResolver = {
|
|
|
119450
119555
|
isBindingCapturedByNode: notImplemented,
|
|
119451
119556
|
getDeclarationStatementsForSourceFile: notImplemented,
|
|
119452
119557
|
isImportRequiredByAugmentation: notImplemented,
|
|
119453
|
-
isDefinitelyReferenceToGlobalSymbolObject: notImplemented
|
|
119558
|
+
isDefinitelyReferenceToGlobalSymbolObject: notImplemented,
|
|
119559
|
+
createLateBoundIndexSignatures: notImplemented
|
|
119454
119560
|
};
|
|
119455
119561
|
var createPrinterWithDefaults = /* @__PURE__ */ memoize(() => createPrinter({}));
|
|
119456
119562
|
var createPrinterWithRemoveComments = /* @__PURE__ */ memoize(() => createPrinter({ removeComments: true }));
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "typescript",
|
|
3
3
|
"author": "Microsoft Corp.",
|
|
4
4
|
"homepage": "https://www.typescriptlang.org/",
|
|
5
|
-
"version": "5.7.0-dev.
|
|
5
|
+
"version": "5.7.0-dev.20240924",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"description": "TypeScript is a language for application scale JavaScript development",
|
|
8
8
|
"keywords": [
|
|
@@ -116,5 +116,5 @@
|
|
|
116
116
|
"node": "20.1.0",
|
|
117
117
|
"npm": "8.19.4"
|
|
118
118
|
},
|
|
119
|
-
"gitHead": "
|
|
119
|
+
"gitHead": "fa0080f4802fd78fb0f01cd0160f299794d7843d"
|
|
120
120
|
}
|