@typescript-deploys/pr-build 5.2.0-pr-55028-5 → 5.2.0-pr-52095-16
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 +151 -82
- package/lib/tsserver.js +315 -145
- package/lib/tsserverlibrary.d.ts +13 -2
- package/lib/tsserverlibrary.js +314 -146
- package/lib/typescript.d.ts +7 -1
- package/lib/typescript.js +296 -142
- package/lib/typingsInstaller.js +11 -4
- 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.2";
|
|
21
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20230725`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -17404,6 +17404,18 @@ function getTextOfJsxNamespacedName(node) {
|
|
|
17404
17404
|
function intrinsicTagNameToString(node) {
|
|
17405
17405
|
return isIdentifier(node) ? idText(node) : getTextOfJsxNamespacedName(node);
|
|
17406
17406
|
}
|
|
17407
|
+
function isTypeUsableAsPropertyName(type) {
|
|
17408
|
+
return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
|
|
17409
|
+
}
|
|
17410
|
+
function getPropertyNameFromType(type) {
|
|
17411
|
+
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
17412
|
+
return type.escapedName;
|
|
17413
|
+
}
|
|
17414
|
+
if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
17415
|
+
return escapeLeadingUnderscores("" + type.value);
|
|
17416
|
+
}
|
|
17417
|
+
return Debug.fail();
|
|
17418
|
+
}
|
|
17407
17419
|
|
|
17408
17420
|
// src/compiler/factory/baseNodeFactory.ts
|
|
17409
17421
|
function createBaseNodeFactory() {
|
|
@@ -30711,10 +30723,14 @@ var Parser;
|
|
|
30711
30723
|
case 124 /* ProtectedKeyword */:
|
|
30712
30724
|
case 125 /* PublicKeyword */:
|
|
30713
30725
|
case 148 /* ReadonlyKeyword */:
|
|
30726
|
+
const previousToken = token();
|
|
30714
30727
|
nextToken();
|
|
30715
30728
|
if (scanner.hasPrecedingLineBreak()) {
|
|
30716
30729
|
return false;
|
|
30717
30730
|
}
|
|
30731
|
+
if (previousToken === 138 /* DeclareKeyword */ && token() === 156 /* TypeKeyword */) {
|
|
30732
|
+
return true;
|
|
30733
|
+
}
|
|
30718
30734
|
continue;
|
|
30719
30735
|
case 162 /* GlobalKeyword */:
|
|
30720
30736
|
nextToken();
|
|
@@ -31079,14 +31095,14 @@ var Parser;
|
|
|
31079
31095
|
function parseObjectBindingPattern() {
|
|
31080
31096
|
const pos = getNodePos();
|
|
31081
31097
|
parseExpected(19 /* OpenBraceToken */);
|
|
31082
|
-
const elements = parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement);
|
|
31098
|
+
const elements = allowInAnd(() => parseDelimitedList(9 /* ObjectBindingElements */, parseObjectBindingElement));
|
|
31083
31099
|
parseExpected(20 /* CloseBraceToken */);
|
|
31084
31100
|
return finishNode(factory2.createObjectBindingPattern(elements), pos);
|
|
31085
31101
|
}
|
|
31086
31102
|
function parseArrayBindingPattern() {
|
|
31087
31103
|
const pos = getNodePos();
|
|
31088
31104
|
parseExpected(23 /* OpenBracketToken */);
|
|
31089
|
-
const elements = parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement);
|
|
31105
|
+
const elements = allowInAnd(() => parseDelimitedList(10 /* ArrayBindingElements */, parseArrayBindingElement));
|
|
31090
31106
|
parseExpected(24 /* CloseBracketToken */);
|
|
31091
31107
|
return finishNode(factory2.createArrayBindingPattern(elements), pos);
|
|
31092
31108
|
}
|
|
@@ -31604,6 +31620,9 @@ var Parser;
|
|
|
31604
31620
|
}
|
|
31605
31621
|
function parseTypeAliasDeclaration(pos, hasJSDoc, modifiers) {
|
|
31606
31622
|
parseExpected(156 /* TypeKeyword */);
|
|
31623
|
+
if (scanner.hasPrecedingLineBreak()) {
|
|
31624
|
+
parseErrorAtCurrentToken(Diagnostics.Line_break_not_permitted_here);
|
|
31625
|
+
}
|
|
31607
31626
|
const name = parseIdentifier();
|
|
31608
31627
|
const typeParameters = parseTypeParameters();
|
|
31609
31628
|
parseExpected(64 /* EqualsToken */);
|
|
@@ -33505,7 +33524,7 @@ function getNamedArgRegEx(name) {
|
|
|
33505
33524
|
return result;
|
|
33506
33525
|
}
|
|
33507
33526
|
var tripleSlashXMLCommentStartRegEx = /^\/\/\/\s*<(\S+)\s.*?\/>/im;
|
|
33508
|
-
var singleLinePragmaRegEx = /^\/\/\/?\s*@(
|
|
33527
|
+
var singleLinePragmaRegEx = /^\/\/\/?\s*@([^\s:]+)(.*)\s*$/im;
|
|
33509
33528
|
function extractPragmas(pragmas, range, text) {
|
|
33510
33529
|
const tripleSlash = range.kind === 2 /* SingleLineCommentTrivia */ && tripleSlashXMLCommentStartRegEx.exec(text);
|
|
33511
33530
|
if (tripleSlash) {
|
|
@@ -39223,6 +39242,9 @@ function getModuleInstanceStateForAliasTarget(specifier, visited) {
|
|
|
39223
39242
|
if (found === 1 /* Instantiated */) {
|
|
39224
39243
|
return found;
|
|
39225
39244
|
}
|
|
39245
|
+
if (statement.kind === 271 /* ImportEqualsDeclaration */) {
|
|
39246
|
+
found = 1 /* Instantiated */;
|
|
39247
|
+
}
|
|
39226
39248
|
}
|
|
39227
39249
|
}
|
|
39228
39250
|
if (found !== void 0) {
|
|
@@ -43111,7 +43133,7 @@ function createTypeChecker(host) {
|
|
|
43111
43133
|
return node ? getTypeFromTypeNode(node) : errorType;
|
|
43112
43134
|
},
|
|
43113
43135
|
getParameterType: getTypeAtPosition,
|
|
43114
|
-
|
|
43136
|
+
getParameterIdentifierInfoAtPosition,
|
|
43115
43137
|
getPromisedTypeOfPromise,
|
|
43116
43138
|
getAwaitedType: (type) => getAwaitedType(type),
|
|
43117
43139
|
getReturnTypeOfSignature,
|
|
@@ -44375,7 +44397,7 @@ function createTypeChecker(host) {
|
|
|
44375
44397
|
false
|
|
44376
44398
|
);
|
|
44377
44399
|
} else if (isParameterPropertyDeclaration(declaration, declaration.parent)) {
|
|
44378
|
-
return !(useDefineForClassFields && getContainingClass(declaration) === getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration));
|
|
44400
|
+
return !(getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && useDefineForClassFields && getContainingClass(declaration) === getContainingClass(usage) && isUsedInFunctionOrInstanceProperty(usage, declaration));
|
|
44379
44401
|
}
|
|
44380
44402
|
return true;
|
|
44381
44403
|
}
|
|
@@ -44389,7 +44411,7 @@ function createTypeChecker(host) {
|
|
|
44389
44411
|
return true;
|
|
44390
44412
|
}
|
|
44391
44413
|
if (isUsedInFunctionOrInstanceProperty(usage, declaration)) {
|
|
44392
|
-
if (useDefineForClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
44414
|
+
if (getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */ && useDefineForClassFields && getContainingClass(declaration) && (isPropertyDeclaration(declaration) || isParameterPropertyDeclaration(declaration, declaration.parent))) {
|
|
44393
44415
|
return !isPropertyImmediatelyReferencedWithinDeclaration(
|
|
44394
44416
|
declaration,
|
|
44395
44417
|
usage,
|
|
@@ -44513,7 +44535,7 @@ function createTypeChecker(host) {
|
|
|
44513
44535
|
return requiresScopeChangeWorker(node.name);
|
|
44514
44536
|
case 172 /* PropertyDeclaration */:
|
|
44515
44537
|
if (hasStaticModifier(node)) {
|
|
44516
|
-
return !useDefineForClassFields;
|
|
44538
|
+
return target < 99 /* ESNext */ || !useDefineForClassFields;
|
|
44517
44539
|
}
|
|
44518
44540
|
return requiresScopeChangeWorker(node.name);
|
|
44519
44541
|
default:
|
|
@@ -44784,7 +44806,7 @@ function createTypeChecker(host) {
|
|
|
44784
44806
|
}
|
|
44785
44807
|
}
|
|
44786
44808
|
function checkAndReportErrorForInvalidInitializer() {
|
|
44787
|
-
if (propertyWithInvalidInitializer && !useDefineForClassFields) {
|
|
44809
|
+
if (propertyWithInvalidInitializer && !(useDefineForClassFields && getEmitScriptTarget(compilerOptions) >= 9 /* ES2022 */)) {
|
|
44788
44810
|
error(
|
|
44789
44811
|
errorLocation,
|
|
44790
44812
|
errorLocation && propertyWithInvalidInitializer.type && textRangeContainsPositionInclusive(propertyWithInvalidInitializer.type, errorLocation.pos) ? Diagnostics.Type_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor : Diagnostics.Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor,
|
|
@@ -46168,7 +46190,7 @@ function createTypeChecker(host) {
|
|
|
46168
46190
|
return isStringLiteralLike(moduleReferenceExpression) ? resolveExternalModule(location, moduleReferenceExpression.text, moduleNotFoundError, moduleReferenceExpression, isForAugmentation) : void 0;
|
|
46169
46191
|
}
|
|
46170
46192
|
function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation = false) {
|
|
46171
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
46193
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
46172
46194
|
if (startsWith(moduleReference, "@types/")) {
|
|
46173
46195
|
const diag2 = Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
|
|
46174
46196
|
const withoutAtTypePrefix = removePrefix(moduleReference, "@types/");
|
|
@@ -46203,8 +46225,11 @@ function createTypeChecker(host) {
|
|
|
46203
46225
|
);
|
|
46204
46226
|
}
|
|
46205
46227
|
} else if (resolvedModule.resolvedUsingTsExtension && !shouldAllowImportingTsExtension(compilerOptions, currentSourceFile.fileName)) {
|
|
46206
|
-
const
|
|
46207
|
-
|
|
46228
|
+
const importOrExport = ((_h = findAncestor(location, isImportDeclaration)) == null ? void 0 : _h.importClause) || findAncestor(location, or(isImportEqualsDeclaration, isExportDeclaration));
|
|
46229
|
+
if (!((importOrExport == null ? void 0 : importOrExport.isTypeOnly) || findAncestor(location, isImportTypeNode))) {
|
|
46230
|
+
const tsExtension = Debug.checkDefined(tryExtractTSExtension(moduleReference));
|
|
46231
|
+
error(errorNode, Diagnostics.An_import_path_can_only_end_with_a_0_extension_when_allowImportingTsExtensions_is_enabled, tsExtension);
|
|
46232
|
+
}
|
|
46208
46233
|
}
|
|
46209
46234
|
if (sourceFile.symbol) {
|
|
46210
46235
|
if (resolvedModule.isExternalLibraryImport && !resolutionExtensionIsTSOrJson(resolvedModule.extension)) {
|
|
@@ -46221,7 +46246,7 @@ function createTypeChecker(host) {
|
|
|
46221
46246
|
if (moduleResolutionKind === 3 /* Node16 */ || moduleResolutionKind === 99 /* NodeNext */) {
|
|
46222
46247
|
const isSyncImport = currentSourceFile.impliedNodeFormat === 1 /* CommonJS */ && !findAncestor(location, isImportCall) || !!findAncestor(location, isImportEqualsDeclaration);
|
|
46223
46248
|
const overrideClauseHost = findAncestor(location, (l) => isImportTypeNode(l) || isExportDeclaration(l) || isImportDeclaration(l));
|
|
46224
|
-
const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? (
|
|
46249
|
+
const overrideClause = overrideClauseHost && isImportTypeNode(overrideClauseHost) ? (_i = overrideClauseHost.assertions) == null ? void 0 : _i.assertClause : overrideClauseHost == null ? void 0 : overrideClauseHost.assertClause;
|
|
46225
46250
|
if (isSyncImport && sourceFile.impliedNodeFormat === 99 /* ESNext */ && !getResolutionModeOverrideForClause(overrideClause)) {
|
|
46226
46251
|
if (findAncestor(location, isImportEqualsDeclaration)) {
|
|
46227
46252
|
error(errorNode, Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_with_require_Use_an_ECMAScript_import_instead, moduleReference);
|
|
@@ -46324,7 +46349,7 @@ function createTypeChecker(host) {
|
|
|
46324
46349
|
error(errorNode, Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
|
|
46325
46350
|
} else if (mode === 99 /* ESNext */ && resolutionIsNode16OrNext && isExtensionlessRelativePathImport) {
|
|
46326
46351
|
const absoluteRef = getNormalizedAbsolutePath(moduleReference, getDirectoryPath(currentSourceFile.path));
|
|
46327
|
-
const suggestedExt = (
|
|
46352
|
+
const suggestedExt = (_j = suggestedExtensions.find(([actualExt, _importExt]) => host.fileExists(absoluteRef + actualExt))) == null ? void 0 : _j[1];
|
|
46328
46353
|
if (suggestedExt) {
|
|
46329
46354
|
error(
|
|
46330
46355
|
errorNode,
|
|
@@ -47760,11 +47785,13 @@ function createTypeChecker(host) {
|
|
|
47760
47785
|
return !!type2.target && isMappedTypeHomomorphic(type2.target) && !isMappedTypeHomomorphic(type2);
|
|
47761
47786
|
}
|
|
47762
47787
|
function createMappedTypeNodeFromType(type2) {
|
|
47788
|
+
var _a2;
|
|
47763
47789
|
Debug.assert(!!(type2.flags & 524288 /* Object */));
|
|
47764
47790
|
const readonlyToken = type2.declaration.readonlyToken ? factory.createToken(type2.declaration.readonlyToken.kind) : void 0;
|
|
47765
47791
|
const questionToken = type2.declaration.questionToken ? factory.createToken(type2.declaration.questionToken.kind) : void 0;
|
|
47766
47792
|
let appropriateConstraintTypeNode;
|
|
47767
47793
|
let newTypeVariable;
|
|
47794
|
+
const needsModifierPreservingWrapper = !isMappedTypeWithKeyofConstraintDeclaration(type2) && !(getModifiersTypeFromMappedType(type2).flags & 2 /* Unknown */) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */ && !(getConstraintTypeFromMappedType(type2).flags & 262144 /* TypeParameter */ && ((_a2 = getConstraintOfTypeParameter(getConstraintTypeFromMappedType(type2))) == null ? void 0 : _a2.flags) & 4194304 /* Index */);
|
|
47768
47795
|
if (isMappedTypeWithKeyofConstraintDeclaration(type2)) {
|
|
47769
47796
|
if (isHomomorphicMappedTypeWithNonHomomorphicInstantiation(type2) && context.flags & 4 /* GenerateNamesForShadowedTypeParams */) {
|
|
47770
47797
|
const newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
@@ -47772,6 +47799,11 @@ function createTypeChecker(host) {
|
|
|
47772
47799
|
newTypeVariable = factory.createTypeReferenceNode(name);
|
|
47773
47800
|
}
|
|
47774
47801
|
appropriateConstraintTypeNode = factory.createTypeOperatorNode(143 /* KeyOfKeyword */, newTypeVariable || typeToTypeNodeHelper(getModifiersTypeFromMappedType(type2), context));
|
|
47802
|
+
} else if (needsModifierPreservingWrapper) {
|
|
47803
|
+
const newParam = createTypeParameter(createSymbol(262144 /* TypeParameter */, "T"));
|
|
47804
|
+
const name = typeParameterToName(newParam, context);
|
|
47805
|
+
newTypeVariable = factory.createTypeReferenceNode(name);
|
|
47806
|
+
appropriateConstraintTypeNode = newTypeVariable;
|
|
47775
47807
|
} else {
|
|
47776
47808
|
appropriateConstraintTypeNode = typeToTypeNodeHelper(getConstraintTypeFromMappedType(type2), context);
|
|
47777
47809
|
}
|
|
@@ -47802,6 +47834,18 @@ function createTypeChecker(host) {
|
|
|
47802
47834
|
result,
|
|
47803
47835
|
factory.createKeywordTypeNode(146 /* NeverKeyword */)
|
|
47804
47836
|
);
|
|
47837
|
+
} else if (needsModifierPreservingWrapper) {
|
|
47838
|
+
return factory.createConditionalTypeNode(
|
|
47839
|
+
typeToTypeNodeHelper(getConstraintTypeFromMappedType(type2), context),
|
|
47840
|
+
factory.createInferTypeNode(factory.createTypeParameterDeclaration(
|
|
47841
|
+
/*modifiers*/
|
|
47842
|
+
void 0,
|
|
47843
|
+
factory.cloneNode(newTypeVariable.typeName),
|
|
47844
|
+
factory.createTypeOperatorNode(143 /* KeyOfKeyword */, typeToTypeNodeHelper(getModifiersTypeFromMappedType(type2), context))
|
|
47845
|
+
)),
|
|
47846
|
+
result,
|
|
47847
|
+
factory.createKeywordTypeNode(146 /* NeverKeyword */)
|
|
47848
|
+
);
|
|
47805
47849
|
}
|
|
47806
47850
|
return result;
|
|
47807
47851
|
}
|
|
@@ -52853,9 +52897,6 @@ function createTypeChecker(host) {
|
|
|
52853
52897
|
}
|
|
52854
52898
|
return type;
|
|
52855
52899
|
}
|
|
52856
|
-
function isTypeUsableAsPropertyName(type) {
|
|
52857
|
-
return !!(type.flags & 8576 /* StringOrNumberLiteralOrUnique */);
|
|
52858
|
-
}
|
|
52859
52900
|
function isLateBindableName(node) {
|
|
52860
52901
|
if (!isComputedPropertyName(node) && !isElementAccessExpression(node)) {
|
|
52861
52902
|
return false;
|
|
@@ -52876,15 +52917,6 @@ function createTypeChecker(host) {
|
|
|
52876
52917
|
function isNonBindableDynamicName(node) {
|
|
52877
52918
|
return isDynamicName(node) && !isLateBindableName(node);
|
|
52878
52919
|
}
|
|
52879
|
-
function getPropertyNameFromType(type) {
|
|
52880
|
-
if (type.flags & 8192 /* UniqueESSymbol */) {
|
|
52881
|
-
return type.escapedName;
|
|
52882
|
-
}
|
|
52883
|
-
if (type.flags & (128 /* StringLiteral */ | 256 /* NumberLiteral */)) {
|
|
52884
|
-
return escapeLeadingUnderscores("" + type.value);
|
|
52885
|
-
}
|
|
52886
|
-
return Debug.fail();
|
|
52887
|
-
}
|
|
52888
52920
|
function addDeclarationToLateBoundSymbol(symbol, member, symbolFlags) {
|
|
52889
52921
|
Debug.assert(!!(getCheckFlags(symbol) & 4096 /* Late */), "Expected a late-bound symbol.");
|
|
52890
52922
|
symbol.flags |= symbolFlags;
|
|
@@ -53531,20 +53563,17 @@ function createTypeChecker(host) {
|
|
|
53531
53563
|
setStructuredTypeMembers(type, members2, callSignatures, constructSignatures, indexInfos2);
|
|
53532
53564
|
return;
|
|
53533
53565
|
}
|
|
53534
|
-
let members =
|
|
53566
|
+
let members = getExportsOfSymbol(symbol);
|
|
53535
53567
|
let indexInfos;
|
|
53536
|
-
if (symbol
|
|
53537
|
-
|
|
53538
|
-
|
|
53539
|
-
|
|
53540
|
-
|
|
53541
|
-
|
|
53542
|
-
|
|
53543
|
-
|
|
53544
|
-
|
|
53545
|
-
});
|
|
53546
|
-
members = varsOnly;
|
|
53547
|
-
}
|
|
53568
|
+
if (symbol === globalThisSymbol) {
|
|
53569
|
+
const varsOnly = /* @__PURE__ */ new Map();
|
|
53570
|
+
members.forEach((p) => {
|
|
53571
|
+
var _a;
|
|
53572
|
+
if (!(p.flags & 418 /* BlockScoped */) && !(p.flags & 512 /* ValueModule */ && ((_a = p.declarations) == null ? void 0 : _a.length) && every(p.declarations, isAmbientModule))) {
|
|
53573
|
+
varsOnly.set(p.escapedName, p);
|
|
53574
|
+
}
|
|
53575
|
+
});
|
|
53576
|
+
members = varsOnly;
|
|
53548
53577
|
}
|
|
53549
53578
|
let baseConstructorIndexInfo;
|
|
53550
53579
|
setStructuredTypeMembers(type, members, emptyArray, emptyArray, emptyArray);
|
|
@@ -67243,41 +67272,75 @@ function createTypeChecker(host) {
|
|
|
67243
67272
|
return mapType(
|
|
67244
67273
|
type,
|
|
67245
67274
|
(t) => {
|
|
67246
|
-
|
|
67247
|
-
|
|
67248
|
-
|
|
67249
|
-
|
|
67250
|
-
const
|
|
67251
|
-
|
|
67252
|
-
|
|
67253
|
-
|
|
67254
|
-
|
|
67255
|
-
|
|
67256
|
-
|
|
67257
|
-
|
|
67258
|
-
}
|
|
67259
|
-
if (isTupleType(t) && isNumericLiteralName(name) && +name >= 0) {
|
|
67260
|
-
const restType = getElementTypeOfSliceOfTupleType(
|
|
67261
|
-
t,
|
|
67262
|
-
t.target.fixedLength,
|
|
67263
|
-
/*endSkipCount*/
|
|
67264
|
-
0,
|
|
67265
|
-
/*writing*/
|
|
67266
|
-
false,
|
|
67267
|
-
/*noReductions*/
|
|
67268
|
-
true
|
|
67269
|
-
);
|
|
67270
|
-
if (restType) {
|
|
67271
|
-
return restType;
|
|
67275
|
+
if (!(t.flags & 3670016 /* StructuredType */)) {
|
|
67276
|
+
return void 0;
|
|
67277
|
+
}
|
|
67278
|
+
if (t.flags & 2097152 /* Intersection */) {
|
|
67279
|
+
const intersection = t;
|
|
67280
|
+
let applicableIndexedMappedTypeSubstitions;
|
|
67281
|
+
let concretePropertyTypes;
|
|
67282
|
+
let applicableIndexInfoCandidates;
|
|
67283
|
+
for (const t2 of intersection.types) {
|
|
67284
|
+
if (isGenericMappedType(t2) && !t2.declaration.nameType) {
|
|
67285
|
+
applicableIndexedMappedTypeSubstitions = append(applicableIndexedMappedTypeSubstitions, getTypeOfApplicableIndexedMappedTypeSubstitutionOfContextualType(t2));
|
|
67286
|
+
continue;
|
|
67272
67287
|
}
|
|
67288
|
+
const typeOfConcreteProperty = getTypeOfConcretePropertyOfContextualType(t2);
|
|
67289
|
+
if (typeOfConcreteProperty) {
|
|
67290
|
+
concretePropertyTypes = append(concretePropertyTypes, typeOfConcreteProperty);
|
|
67291
|
+
continue;
|
|
67292
|
+
}
|
|
67293
|
+
applicableIndexInfoCandidates = append(applicableIndexInfoCandidates, t2);
|
|
67294
|
+
}
|
|
67295
|
+
if (concretePropertyTypes) {
|
|
67296
|
+
return getIntersectionType(concatenate(concretePropertyTypes, applicableIndexedMappedTypeSubstitions));
|
|
67273
67297
|
}
|
|
67274
|
-
|
|
67298
|
+
const types = concatenate(mapDefined(applicableIndexInfoCandidates, getTypeOfApplicableIndexInfoOfContextualType), applicableIndexedMappedTypeSubstitions);
|
|
67299
|
+
if (types.length > 0) {
|
|
67300
|
+
return getIntersectionType(types);
|
|
67301
|
+
}
|
|
67302
|
+
return void 0;
|
|
67275
67303
|
}
|
|
67276
|
-
return
|
|
67304
|
+
return isGenericMappedType(t) && !t.declaration.nameType ? getTypeOfApplicableIndexedMappedTypeSubstitutionOfContextualType(t) : getTypeOfConcretePropertyOfContextualType(t) || getTypeOfApplicableIndexInfoOfContextualType(t);
|
|
67277
67305
|
},
|
|
67278
67306
|
/*noReductions*/
|
|
67279
67307
|
true
|
|
67280
67308
|
);
|
|
67309
|
+
function getTypeOfApplicableIndexedMappedTypeSubstitutionOfContextualType(t) {
|
|
67310
|
+
const constraint = getConstraintTypeFromMappedType(t);
|
|
67311
|
+
const constraintOfConstraint = getBaseConstraintOfType(constraint) || constraint;
|
|
67312
|
+
const propertyNameType = nameType || getStringLiteralType(unescapeLeadingUnderscores(name));
|
|
67313
|
+
if (isTypeAssignableTo(propertyNameType, constraintOfConstraint)) {
|
|
67314
|
+
return substituteIndexedMappedType(t, propertyNameType);
|
|
67315
|
+
}
|
|
67316
|
+
return void 0;
|
|
67317
|
+
}
|
|
67318
|
+
function getTypeOfConcretePropertyOfContextualType(t) {
|
|
67319
|
+
const prop = getPropertyOfType(t, name);
|
|
67320
|
+
if (prop) {
|
|
67321
|
+
return isCircularMappedProperty(prop) ? void 0 : getTypeOfSymbol(prop);
|
|
67322
|
+
}
|
|
67323
|
+
if (isTupleType(t) && isNumericLiteralName(name) && +name >= 0) {
|
|
67324
|
+
const restType = getElementTypeOfSliceOfTupleType(
|
|
67325
|
+
t,
|
|
67326
|
+
t.target.fixedLength,
|
|
67327
|
+
/*endSkipCount*/
|
|
67328
|
+
0,
|
|
67329
|
+
/*writing*/
|
|
67330
|
+
false,
|
|
67331
|
+
/*noReductions*/
|
|
67332
|
+
true
|
|
67333
|
+
);
|
|
67334
|
+
if (restType) {
|
|
67335
|
+
return restType;
|
|
67336
|
+
}
|
|
67337
|
+
}
|
|
67338
|
+
return void 0;
|
|
67339
|
+
}
|
|
67340
|
+
function getTypeOfApplicableIndexInfoOfContextualType(t) {
|
|
67341
|
+
var _a;
|
|
67342
|
+
return (_a = findApplicableIndexInfo(getIndexInfosOfStructuredType(t), nameType || getStringLiteralType(unescapeLeadingUnderscores(name)))) == null ? void 0 : _a.type;
|
|
67343
|
+
}
|
|
67281
67344
|
}
|
|
67282
67345
|
function getContextualTypeForObjectLiteralMethod(node, contextFlags) {
|
|
67283
67346
|
Debug.assert(isObjectLiteralMethod(node));
|
|
@@ -69362,7 +69425,7 @@ function createTypeChecker(host) {
|
|
|
69362
69425
|
}
|
|
69363
69426
|
let diagnosticMessage;
|
|
69364
69427
|
const declarationName = idText(right);
|
|
69365
|
-
if (isInPropertyInitializerOrClassStaticBlock(node) && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlagsCached(valueDeclaration) & 32 /* Static */) && (useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) {
|
|
69428
|
+
if (isInPropertyInitializerOrClassStaticBlock(node) && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlagsCached(valueDeclaration) & 32 /* Static */) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) {
|
|
69366
69429
|
diagnosticMessage = error(right, Diagnostics.Property_0_is_used_before_its_initialization, declarationName);
|
|
69367
69430
|
} else if (valueDeclaration.kind === 263 /* ClassDeclaration */ && node.parent.kind !== 183 /* TypeReference */ && !(valueDeclaration.flags & 33554432 /* Ambient */) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right)) {
|
|
69368
69431
|
diagnosticMessage = error(right, Diagnostics.Class_0_used_before_its_declaration, declarationName);
|
|
@@ -72056,7 +72119,7 @@ function createTypeChecker(host) {
|
|
|
72056
72119
|
}
|
|
72057
72120
|
return restParameter.escapedName;
|
|
72058
72121
|
}
|
|
72059
|
-
function
|
|
72122
|
+
function getParameterIdentifierInfoAtPosition(signature, pos) {
|
|
72060
72123
|
var _a;
|
|
72061
72124
|
if (((_a = signature.declaration) == null ? void 0 : _a.kind) === 324 /* JSDocFunctionType */) {
|
|
72062
72125
|
return void 0;
|
|
@@ -72064,10 +72127,16 @@ function createTypeChecker(host) {
|
|
|
72064
72127
|
const paramCount = signature.parameters.length - (signatureHasRestParameter(signature) ? 1 : 0);
|
|
72065
72128
|
if (pos < paramCount) {
|
|
72066
72129
|
const param = signature.parameters[pos];
|
|
72067
|
-
|
|
72130
|
+
const paramIdent = getParameterDeclarationIdentifier(param);
|
|
72131
|
+
return paramIdent ? {
|
|
72132
|
+
parameter: paramIdent,
|
|
72133
|
+
parameterName: param.escapedName,
|
|
72134
|
+
isRestParameter: false
|
|
72135
|
+
} : void 0;
|
|
72068
72136
|
}
|
|
72069
72137
|
const restParameter = signature.parameters[paramCount] || unknownSymbol;
|
|
72070
|
-
|
|
72138
|
+
const restIdent = getParameterDeclarationIdentifier(restParameter);
|
|
72139
|
+
if (!restIdent) {
|
|
72071
72140
|
return void 0;
|
|
72072
72141
|
}
|
|
72073
72142
|
const restType = getTypeOfSymbol(restParameter);
|
|
@@ -72076,18 +72145,19 @@ function createTypeChecker(host) {
|
|
|
72076
72145
|
const index = pos - paramCount;
|
|
72077
72146
|
const associatedName = associatedNames == null ? void 0 : associatedNames[index];
|
|
72078
72147
|
const isRestTupleElement = !!(associatedName == null ? void 0 : associatedName.dotDotDotToken);
|
|
72079
|
-
|
|
72080
|
-
|
|
72081
|
-
isRestTupleElement
|
|
72082
|
-
|
|
72148
|
+
if (associatedName) {
|
|
72149
|
+
Debug.assert(isIdentifier(associatedName.name));
|
|
72150
|
+
return { parameter: associatedName.name, parameterName: associatedName.name.escapedText, isRestParameter: isRestTupleElement };
|
|
72151
|
+
}
|
|
72152
|
+
return void 0;
|
|
72083
72153
|
}
|
|
72084
72154
|
if (pos === paramCount) {
|
|
72085
|
-
return
|
|
72155
|
+
return { parameter: restIdent, parameterName: restParameter.escapedName, isRestParameter: true };
|
|
72086
72156
|
}
|
|
72087
72157
|
return void 0;
|
|
72088
72158
|
}
|
|
72089
|
-
function
|
|
72090
|
-
return symbol.valueDeclaration && isParameter(symbol.valueDeclaration) && isIdentifier(symbol.valueDeclaration.name);
|
|
72159
|
+
function getParameterDeclarationIdentifier(symbol) {
|
|
72160
|
+
return symbol.valueDeclaration && isParameter(symbol.valueDeclaration) && isIdentifier(symbol.valueDeclaration.name) && symbol.valueDeclaration.name;
|
|
72091
72161
|
}
|
|
72092
72162
|
function isValidDeclarationForTupleLabel(d) {
|
|
72093
72163
|
return d.kind === 202 /* NamedTupleMember */ || isParameter(d) && d.name && isIdentifier(d.name);
|
|
@@ -75056,7 +75126,7 @@ function createTypeChecker(host) {
|
|
|
75056
75126
|
case "length":
|
|
75057
75127
|
case "caller":
|
|
75058
75128
|
case "arguments":
|
|
75059
|
-
if (useDefineForClassFields) {
|
|
75129
|
+
if (compilerOptions.useDefineForClassFields) {
|
|
75060
75130
|
break;
|
|
75061
75131
|
}
|
|
75062
75132
|
case "prototype":
|
|
@@ -75204,7 +75274,7 @@ function createTypeChecker(host) {
|
|
|
75204
75274
|
if (classExtendsNull) {
|
|
75205
75275
|
error(superCall, Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
|
|
75206
75276
|
}
|
|
75207
|
-
const superCallShouldBeRootLevel = !useDefineForClassFields && (some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, (p) => hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */)));
|
|
75277
|
+
const superCallShouldBeRootLevel = (getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) && (some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) || some(node.parameters, (p) => hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */)));
|
|
75208
75278
|
if (superCallShouldBeRootLevel) {
|
|
75209
75279
|
if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
|
|
75210
75280
|
error(superCall, Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers);
|
|
@@ -78474,7 +78544,7 @@ function createTypeChecker(host) {
|
|
|
78474
78544
|
node
|
|
78475
78545
|
);
|
|
78476
78546
|
const willTransformPrivateElementsOrClassStaticBlocks = languageVersion <= 9 /* ES2022 */;
|
|
78477
|
-
const willTransformInitializers = !useDefineForClassFields
|
|
78547
|
+
const willTransformInitializers = !useDefineForClassFields || languageVersion < 9 /* ES2022 */;
|
|
78478
78548
|
if (willTransformStaticElementsOfDecoratedClass || willTransformPrivateElementsOrClassStaticBlocks) {
|
|
78479
78549
|
for (const member of node.members) {
|
|
78480
78550
|
if (willTransformStaticElementsOfDecoratedClass && classElementOrClassElementParameterIsDecorated(
|
|
@@ -122037,7 +122107,6 @@ function createWatchProgram(host) {
|
|
|
122037
122107
|
if (hasChangedCompilerOptions) {
|
|
122038
122108
|
newLine = updateNewLine();
|
|
122039
122109
|
if (program && changesAffectModuleResolution(program.getCompilerOptions(), compilerOptions)) {
|
|
122040
|
-
debugger;
|
|
122041
122110
|
resolutionCache.onChangesAffectModuleResolution();
|
|
122042
122111
|
}
|
|
122043
122112
|
}
|