@typescript-deploys/pr-build 5.4.0-pr-56034-9 → 5.4.0-pr-49218-45
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 +227 -121
- package/lib/tsserver.js +291 -162
- package/lib/typescript.d.ts +8 -1
- package/lib/typescript.js +291 -160
- package/lib/typingsInstaller.js +2 -2
- package/package.json +3 -3
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.4";
|
|
21
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20240110`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -12673,7 +12673,7 @@ function isPartOfTypeNode(node) {
|
|
|
12673
12673
|
case 116 /* VoidKeyword */:
|
|
12674
12674
|
return node.parent.kind !== 222 /* VoidExpression */;
|
|
12675
12675
|
case 233 /* ExpressionWithTypeArguments */:
|
|
12676
|
-
return
|
|
12676
|
+
return isPartOfTypeExpressionWithTypeArguments(node);
|
|
12677
12677
|
case 168 /* TypeParameter */:
|
|
12678
12678
|
return node.parent.kind === 200 /* MappedType */ || node.parent.kind === 195 /* InferType */;
|
|
12679
12679
|
case 80 /* Identifier */:
|
|
@@ -12698,7 +12698,7 @@ function isPartOfTypeNode(node) {
|
|
|
12698
12698
|
}
|
|
12699
12699
|
switch (parent.kind) {
|
|
12700
12700
|
case 233 /* ExpressionWithTypeArguments */:
|
|
12701
|
-
return
|
|
12701
|
+
return isPartOfTypeExpressionWithTypeArguments(parent);
|
|
12702
12702
|
case 168 /* TypeParameter */:
|
|
12703
12703
|
return node === parent.constraint;
|
|
12704
12704
|
case 352 /* JSDocTemplateTag */:
|
|
@@ -12732,6 +12732,9 @@ function isPartOfTypeNode(node) {
|
|
|
12732
12732
|
}
|
|
12733
12733
|
return false;
|
|
12734
12734
|
}
|
|
12735
|
+
function isPartOfTypeExpressionWithTypeArguments(node) {
|
|
12736
|
+
return isJSDocImplementsTag(node.parent) || isJSDocAugmentsTag(node.parent) || isHeritageClause(node.parent) && !isExpressionWithTypeArgumentsInClassExtendsClause(node);
|
|
12737
|
+
}
|
|
12735
12738
|
function forEachReturnStatement(body, visitor) {
|
|
12736
12739
|
return traverse(body);
|
|
12737
12740
|
function traverse(node) {
|
|
@@ -16070,7 +16073,7 @@ function Symbol4(flags, name) {
|
|
|
16070
16073
|
this.exportSymbol = void 0;
|
|
16071
16074
|
this.constEnumOnlyModule = void 0;
|
|
16072
16075
|
this.isReferenced = void 0;
|
|
16073
|
-
this.
|
|
16076
|
+
this.lastAssignmentPos = void 0;
|
|
16074
16077
|
this.links = void 0;
|
|
16075
16078
|
}
|
|
16076
16079
|
function Type3(checker, flags) {
|
|
@@ -17495,10 +17498,6 @@ function isInfinityOrNaNString(name) {
|
|
|
17495
17498
|
function isCatchClauseVariableDeclaration(node) {
|
|
17496
17499
|
return node.kind === 260 /* VariableDeclaration */ && node.parent.kind === 299 /* CatchClause */;
|
|
17497
17500
|
}
|
|
17498
|
-
function isParameterOrCatchClauseVariable(symbol) {
|
|
17499
|
-
const declaration = symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration);
|
|
17500
|
-
return !!declaration && (isParameter(declaration) || isCatchClauseVariableDeclaration(declaration));
|
|
17501
|
-
}
|
|
17502
17501
|
function isFunctionExpressionOrArrowFunction(node) {
|
|
17503
17502
|
return node.kind === 218 /* FunctionExpression */ || node.kind === 219 /* ArrowFunction */;
|
|
17504
17503
|
}
|
|
@@ -17672,9 +17671,6 @@ var stringReplace = String.prototype.replace;
|
|
|
17672
17671
|
function replaceFirstStar(s, replacement) {
|
|
17673
17672
|
return stringReplace.call(s, "*", replacement);
|
|
17674
17673
|
}
|
|
17675
|
-
function getNameFromImportAttribute(node) {
|
|
17676
|
-
return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
|
|
17677
|
-
}
|
|
17678
17674
|
|
|
17679
17675
|
// src/compiler/factory/baseNodeFactory.ts
|
|
17680
17676
|
function createBaseNodeFactory() {
|
|
@@ -44288,6 +44284,14 @@ function createTypeChecker(host) {
|
|
|
44288
44284
|
emptyArray,
|
|
44289
44285
|
emptyArray
|
|
44290
44286
|
);
|
|
44287
|
+
var resolvingApparentMappedType = createAnonymousType(
|
|
44288
|
+
/*symbol*/
|
|
44289
|
+
void 0,
|
|
44290
|
+
emptySymbols,
|
|
44291
|
+
emptyArray,
|
|
44292
|
+
emptyArray,
|
|
44293
|
+
emptyArray
|
|
44294
|
+
);
|
|
44291
44295
|
var markerSuperType = createTypeParameter();
|
|
44292
44296
|
var markerSubType = createTypeParameter();
|
|
44293
44297
|
markerSubType.constraint = markerSuperType;
|
|
@@ -44442,7 +44446,6 @@ function createTypeChecker(host) {
|
|
|
44442
44446
|
var deferredGlobalImportMetaType;
|
|
44443
44447
|
var deferredGlobalImportMetaExpressionType;
|
|
44444
44448
|
var deferredGlobalImportCallOptionsType;
|
|
44445
|
-
var deferredGlobalImportAttributesType;
|
|
44446
44449
|
var deferredGlobalDisposableType;
|
|
44447
44450
|
var deferredGlobalAsyncDisposableType;
|
|
44448
44451
|
var deferredGlobalExtractSymbol;
|
|
@@ -47338,29 +47341,7 @@ function createTypeChecker(host) {
|
|
|
47338
47341
|
function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
|
|
47339
47342
|
const container = getParentOfSymbol(symbol);
|
|
47340
47343
|
if (container && !(symbol.flags & 262144 /* TypeParameter */)) {
|
|
47341
|
-
|
|
47342
|
-
const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
|
|
47343
|
-
const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning);
|
|
47344
|
-
if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
|
|
47345
|
-
container,
|
|
47346
|
-
enclosingDeclaration,
|
|
47347
|
-
1920 /* Namespace */,
|
|
47348
|
-
/*useOnlyExternalAliasing*/
|
|
47349
|
-
false
|
|
47350
|
-
)) {
|
|
47351
|
-
return append(concatenate(concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer);
|
|
47352
|
-
}
|
|
47353
|
-
const firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) && container.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
|
|
47354
|
-
return forEachEntry(t, (s) => {
|
|
47355
|
-
if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) {
|
|
47356
|
-
return s;
|
|
47357
|
-
}
|
|
47358
|
-
});
|
|
47359
|
-
}) : void 0;
|
|
47360
|
-
let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container] : [...additionalContainers, container];
|
|
47361
|
-
res = append(res, objectLiteralContainer);
|
|
47362
|
-
res = addRange(res, reexportContainers);
|
|
47363
|
-
return res;
|
|
47344
|
+
return getWithAlternativeContainers(container);
|
|
47364
47345
|
}
|
|
47365
47346
|
const candidates = mapDefined(symbol.declarations, (d) => {
|
|
47366
47347
|
if (!isAmbientModule(d) && d.parent) {
|
|
@@ -47382,7 +47363,40 @@ function createTypeChecker(host) {
|
|
|
47382
47363
|
if (!length(candidates)) {
|
|
47383
47364
|
return void 0;
|
|
47384
47365
|
}
|
|
47385
|
-
|
|
47366
|
+
const containers = mapDefined(candidates, (candidate) => getAliasForSymbolInContainer(candidate, symbol) ? candidate : void 0);
|
|
47367
|
+
let bestContainers = [];
|
|
47368
|
+
let alternativeContainers = [];
|
|
47369
|
+
for (const container2 of containers) {
|
|
47370
|
+
const [bestMatch, ...rest] = getWithAlternativeContainers(container2);
|
|
47371
|
+
bestContainers = append(bestContainers, bestMatch);
|
|
47372
|
+
alternativeContainers = addRange(alternativeContainers, rest);
|
|
47373
|
+
}
|
|
47374
|
+
return concatenate(bestContainers, alternativeContainers);
|
|
47375
|
+
function getWithAlternativeContainers(container2) {
|
|
47376
|
+
const additionalContainers = mapDefined(container2.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
|
|
47377
|
+
const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
|
|
47378
|
+
const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container2, meaning);
|
|
47379
|
+
if (enclosingDeclaration && container2.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
|
|
47380
|
+
container2,
|
|
47381
|
+
enclosingDeclaration,
|
|
47382
|
+
1920 /* Namespace */,
|
|
47383
|
+
/*useOnlyExternalAliasing*/
|
|
47384
|
+
false
|
|
47385
|
+
)) {
|
|
47386
|
+
return append(concatenate(concatenate([container2], additionalContainers), reexportContainers), objectLiteralContainer);
|
|
47387
|
+
}
|
|
47388
|
+
const firstVariableMatch = !(container2.flags & getQualifiedLeftMeaning(meaning)) && container2.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container2).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
|
|
47389
|
+
return forEachEntry(t, (s) => {
|
|
47390
|
+
if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container2)) {
|
|
47391
|
+
return s;
|
|
47392
|
+
}
|
|
47393
|
+
});
|
|
47394
|
+
}) : void 0;
|
|
47395
|
+
let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container2] : [...additionalContainers, container2];
|
|
47396
|
+
res = append(res, objectLiteralContainer);
|
|
47397
|
+
res = addRange(res, reexportContainers);
|
|
47398
|
+
return res;
|
|
47399
|
+
}
|
|
47386
47400
|
function fileSymbolIfFileSymbolExportEqualsContainer(d) {
|
|
47387
47401
|
return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
|
|
47388
47402
|
}
|
|
@@ -47420,6 +47434,13 @@ function createTypeChecker(host) {
|
|
|
47420
47434
|
});
|
|
47421
47435
|
}
|
|
47422
47436
|
function getSymbolIfSameReference(s1, s2) {
|
|
47437
|
+
var _a, _b;
|
|
47438
|
+
if (s1.flags & 524288 /* TypeAlias */ && ((_a = s2.declarations) == null ? void 0 : _a.find(isTypeAlias))) {
|
|
47439
|
+
s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
|
|
47440
|
+
}
|
|
47441
|
+
if (s2.flags & 524288 /* TypeAlias */ && ((_b = s1.declarations) == null ? void 0 : _b.find(isTypeAlias))) {
|
|
47442
|
+
s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
|
|
47443
|
+
}
|
|
47423
47444
|
if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
|
|
47424
47445
|
return s1;
|
|
47425
47446
|
}
|
|
@@ -52743,24 +52764,6 @@ function createTypeChecker(host) {
|
|
|
52743
52764
|
0 /* Normal */
|
|
52744
52765
|
), declaration, reportErrors2);
|
|
52745
52766
|
}
|
|
52746
|
-
function getTypeFromImportAttributes(node) {
|
|
52747
|
-
const links = getNodeLinks(node);
|
|
52748
|
-
if (!links.resolvedType) {
|
|
52749
|
-
const symbol = createSymbol(4096 /* ObjectLiteral */, "__importAttributes" /* ImportAttributes */);
|
|
52750
|
-
const members = createSymbolTable();
|
|
52751
|
-
forEach(node.elements, (attr) => {
|
|
52752
|
-
const member = createSymbol(4 /* Property */, getNameFromImportAttribute(attr));
|
|
52753
|
-
member.parent = symbol;
|
|
52754
|
-
member.links.type = checkImportAttribute(attr);
|
|
52755
|
-
member.links.target = member;
|
|
52756
|
-
members.set(member.escapedName, member);
|
|
52757
|
-
});
|
|
52758
|
-
const type = createAnonymousType(symbol, members, emptyArray, emptyArray, emptyArray);
|
|
52759
|
-
type.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* NonInferrableType */;
|
|
52760
|
-
links.resolvedType = type;
|
|
52761
|
-
}
|
|
52762
|
-
return links.resolvedType;
|
|
52763
|
-
}
|
|
52764
52767
|
function isGlobalSymbolConstructor(node) {
|
|
52765
52768
|
const symbol = getSymbolOfNode(node);
|
|
52766
52769
|
const globalSymbol = getGlobalESSymbolConstructorTypeSymbol(
|
|
@@ -55176,14 +55179,30 @@ function createTypeChecker(host) {
|
|
|
55176
55179
|
return !!(typeParameter.symbol && forEach(typeParameter.symbol.declarations, (decl) => isTypeParameterDeclaration(decl) && decl.default));
|
|
55177
55180
|
}
|
|
55178
55181
|
function getApparentTypeOfMappedType(type) {
|
|
55179
|
-
|
|
55182
|
+
if (type.resolvedApparentType) {
|
|
55183
|
+
if (type.resolvedApparentType === resolvingApparentMappedType) {
|
|
55184
|
+
return type.resolvedApparentType = type;
|
|
55185
|
+
}
|
|
55186
|
+
return type.resolvedApparentType;
|
|
55187
|
+
}
|
|
55188
|
+
type.resolvedApparentType = resolvingApparentMappedType;
|
|
55189
|
+
return type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type);
|
|
55180
55190
|
}
|
|
55181
55191
|
function getResolvedApparentTypeOfMappedType(type) {
|
|
55182
|
-
const
|
|
55183
|
-
|
|
55184
|
-
|
|
55192
|
+
const mappedType = type.target || type;
|
|
55193
|
+
const typeVariable = getHomomorphicTypeVariable(mappedType);
|
|
55194
|
+
if (typeVariable && !mappedType.declaration.nameType) {
|
|
55195
|
+
let constraint;
|
|
55196
|
+
if (!type.target) {
|
|
55197
|
+
constraint = getConstraintOfTypeParameter(typeVariable);
|
|
55198
|
+
} else {
|
|
55199
|
+
const modifiersConstraint = getConstraintOfType(getModifiersTypeFromMappedType(type));
|
|
55200
|
+
if (modifiersConstraint) {
|
|
55201
|
+
constraint = getApparentType(modifiersConstraint);
|
|
55202
|
+
}
|
|
55203
|
+
}
|
|
55185
55204
|
if (constraint && everyType(constraint, isArrayOrTupleType)) {
|
|
55186
|
-
return instantiateType(
|
|
55205
|
+
return instantiateType(mappedType, prependTypeMapping(typeVariable, constraint, mappedType.mapper));
|
|
55187
55206
|
}
|
|
55188
55207
|
}
|
|
55189
55208
|
return type;
|
|
@@ -55274,6 +55293,7 @@ function createTypeChecker(host) {
|
|
|
55274
55293
|
clone2.parent = (_c = (_b = singleProp.valueDeclaration) == null ? void 0 : _b.symbol) == null ? void 0 : _c.parent;
|
|
55275
55294
|
clone2.links.containingType = containingType;
|
|
55276
55295
|
clone2.links.mapper = links == null ? void 0 : links.mapper;
|
|
55296
|
+
clone2.links.writeType = getWriteTypeOfSymbol(singleProp);
|
|
55277
55297
|
return clone2;
|
|
55278
55298
|
} else {
|
|
55279
55299
|
return singleProp;
|
|
@@ -56742,14 +56762,6 @@ function createTypeChecker(host) {
|
|
|
56742
56762
|
reportErrors2
|
|
56743
56763
|
)) || emptyObjectType;
|
|
56744
56764
|
}
|
|
56745
|
-
function getGlobalImportAttributesType(reportErrors2) {
|
|
56746
|
-
return deferredGlobalImportAttributesType || (deferredGlobalImportAttributesType = getGlobalType(
|
|
56747
|
-
"ImportAttributes",
|
|
56748
|
-
/*arity*/
|
|
56749
|
-
0,
|
|
56750
|
-
reportErrors2
|
|
56751
|
-
)) || emptyObjectType;
|
|
56752
|
-
}
|
|
56753
56765
|
function getGlobalESSymbolConstructorSymbol(reportErrors2) {
|
|
56754
56766
|
return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors2));
|
|
56755
56767
|
}
|
|
@@ -60517,7 +60529,37 @@ function createTypeChecker(host) {
|
|
|
60517
60529
|
const restIndex = sourceRestType || targetRestType ? paramCount - 1 : -1;
|
|
60518
60530
|
for (let i = 0; i < paramCount; i++) {
|
|
60519
60531
|
const sourceType = i === restIndex ? getRestTypeAtPosition(source, i) : tryGetTypeAtPosition(source, i);
|
|
60520
|
-
|
|
60532
|
+
let targetType = i === restIndex ? getRestTypeAtPosition(target, i) : tryGetTypeAtPosition(target, i);
|
|
60533
|
+
if (i === restIndex && targetType && sourceType && isTupleType(sourceType)) {
|
|
60534
|
+
targetType = mapType(targetType, (t) => {
|
|
60535
|
+
if (!isTupleType(t) || // When both sides are tuples of the same structure, we don't want to "propagate" types from elements of variable positions
|
|
60536
|
+
// to the following positions as that would disallow signatures of the exact same structures when trailing fixed elements are involved:
|
|
60537
|
+
//
|
|
60538
|
+
// let fn: (...rest: [...string[], number]) => void = (...rest: [...string[], number]) => {}; // ok
|
|
60539
|
+
//
|
|
60540
|
+
// Since we want to allow contextual types to flow into paremeters, we don't need to differentiate between rest and variadic elements
|
|
60541
|
+
// as that doesn't affect the contextual type of the parameter
|
|
60542
|
+
isTupleTypeStructureMatching(sourceType, t, 2 /* MatchVariable */)) {
|
|
60543
|
+
return t;
|
|
60544
|
+
}
|
|
60545
|
+
const elementTypes = [];
|
|
60546
|
+
const elementFlags = [];
|
|
60547
|
+
const sourceArity = getTypeReferenceArity(sourceType);
|
|
60548
|
+
const targetArity = getTypeReferenceArity(t);
|
|
60549
|
+
for (let i2 = 0; i2 < sourceArity; i2++) {
|
|
60550
|
+
if (i2 >= targetArity) {
|
|
60551
|
+
if (sourceType.target.elementFlags[i2] & 3 /* Fixed */) {
|
|
60552
|
+
elementTypes.push(undefinedType);
|
|
60553
|
+
elementFlags.push(sourceType.target.elementFlags[i2]);
|
|
60554
|
+
}
|
|
60555
|
+
continue;
|
|
60556
|
+
}
|
|
60557
|
+
elementTypes.push(getTupleElementType(t, i2));
|
|
60558
|
+
elementFlags.push(sourceType.target.elementFlags[i2]);
|
|
60559
|
+
}
|
|
60560
|
+
return createTupleType(elementTypes, elementFlags);
|
|
60561
|
+
});
|
|
60562
|
+
}
|
|
60521
60563
|
if (sourceType && targetType) {
|
|
60522
60564
|
const sourceSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(source, i) ? void 0 : getSingleCallSignature(getNonNullableType(sourceType));
|
|
60523
60565
|
const targetSig = checkMode & 3 /* Callback */ || isInstantiatedGenericParameter(target, i) ? void 0 : getSingleCallSignature(getNonNullableType(targetType));
|
|
@@ -61907,6 +61949,18 @@ function createTypeChecker(host) {
|
|
|
61907
61949
|
}
|
|
61908
61950
|
return result2;
|
|
61909
61951
|
}
|
|
61952
|
+
function getApparentMappedTypeKeys(nameType, targetType) {
|
|
61953
|
+
const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
|
|
61954
|
+
const mappedKeys = [];
|
|
61955
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
61956
|
+
modifiersType,
|
|
61957
|
+
8576 /* StringOrNumberLiteralOrUnique */,
|
|
61958
|
+
/*stringsOnly*/
|
|
61959
|
+
false,
|
|
61960
|
+
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
61961
|
+
);
|
|
61962
|
+
return getUnionType(mappedKeys);
|
|
61963
|
+
}
|
|
61910
61964
|
function structuredTypeRelatedToWorker(source2, target2, reportErrors2, intersectionState, saveErrorInfo) {
|
|
61911
61965
|
let result2;
|
|
61912
61966
|
let originalErrorInfo;
|
|
@@ -62089,16 +62143,8 @@ function createTypeChecker(host) {
|
|
|
62089
62143
|
const constraintType = getConstraintTypeFromMappedType(targetType);
|
|
62090
62144
|
let targetKeys;
|
|
62091
62145
|
if (nameType && isMappedTypeWithKeyofConstraintDeclaration(targetType)) {
|
|
62092
|
-
const
|
|
62093
|
-
|
|
62094
|
-
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
62095
|
-
modifiersType,
|
|
62096
|
-
8576 /* StringOrNumberLiteralOrUnique */,
|
|
62097
|
-
/*stringsOnly*/
|
|
62098
|
-
false,
|
|
62099
|
-
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
62100
|
-
);
|
|
62101
|
-
targetKeys = getUnionType([...mappedKeys, nameType]);
|
|
62146
|
+
const mappedKeys = getApparentMappedTypeKeys(nameType, targetType);
|
|
62147
|
+
targetKeys = getUnionType([mappedKeys, nameType]);
|
|
62102
62148
|
} else {
|
|
62103
62149
|
targetKeys = nameType || constraintType;
|
|
62104
62150
|
}
|
|
@@ -62269,9 +62315,18 @@ function createTypeChecker(host) {
|
|
|
62269
62315
|
}
|
|
62270
62316
|
}
|
|
62271
62317
|
} else if (sourceFlags & 4194304 /* Index */) {
|
|
62272
|
-
|
|
62318
|
+
const isDeferredMappedIndex = shouldDeferIndexType(source2.type, source2.indexFlags) && getObjectFlags(source2.type) & 32 /* Mapped */;
|
|
62319
|
+
if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2 && !isDeferredMappedIndex)) {
|
|
62273
62320
|
return result2;
|
|
62274
62321
|
}
|
|
62322
|
+
if (isDeferredMappedIndex) {
|
|
62323
|
+
const mappedType = source2.type;
|
|
62324
|
+
const nameType = getNameTypeFromMappedType(mappedType);
|
|
62325
|
+
const sourceMappedKeys = nameType && isMappedTypeWithKeyofConstraintDeclaration(mappedType) ? getApparentMappedTypeKeys(nameType, mappedType) : nameType || getConstraintTypeFromMappedType(mappedType);
|
|
62326
|
+
if (result2 = isRelatedTo(sourceMappedKeys, target2, 1 /* Source */, reportErrors2)) {
|
|
62327
|
+
return result2;
|
|
62328
|
+
}
|
|
62329
|
+
}
|
|
62275
62330
|
} else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
|
|
62276
62331
|
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
62277
62332
|
const constraint = getBaseConstraintOfType(source2);
|
|
@@ -63761,8 +63816,11 @@ function createTypeChecker(host) {
|
|
|
63761
63816
|
}
|
|
63762
63817
|
return void 0;
|
|
63763
63818
|
}
|
|
63764
|
-
function isTupleTypeStructureMatching(t1, t2) {
|
|
63765
|
-
return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && every(t1.target.elementFlags, (
|
|
63819
|
+
function isTupleTypeStructureMatching(t1, t2, tupleStructureComparisonKind) {
|
|
63820
|
+
return getTypeReferenceArity(t1) === getTypeReferenceArity(t2) && every(t1.target.elementFlags, (f1, i) => {
|
|
63821
|
+
const f2 = t2.target.elementFlags[i];
|
|
63822
|
+
return f1 === f2 || !!(tupleStructureComparisonKind & 1 /* MatchFixed */ && f1 & 3 /* Fixed */ && f2 & 3 /* Fixed */) || !!(tupleStructureComparisonKind & 2 /* MatchVariable */ && f1 & 12 /* Variable */ && f2 & 12 /* Variable */);
|
|
63823
|
+
});
|
|
63766
63824
|
}
|
|
63767
63825
|
function isZeroBigInt({ value }) {
|
|
63768
63826
|
return value.base10Value === "0";
|
|
@@ -64970,7 +65028,7 @@ function createTypeChecker(host) {
|
|
|
64970
65028
|
const targetArity = getTypeReferenceArity(target);
|
|
64971
65029
|
const elementTypes = getTypeArguments(target);
|
|
64972
65030
|
const elementFlags = target.target.elementFlags;
|
|
64973
|
-
if (isTupleType(source) && isTupleTypeStructureMatching(source, target)) {
|
|
65031
|
+
if (isTupleType(source) && isTupleTypeStructureMatching(source, target, 1 /* MatchFixed */)) {
|
|
64974
65032
|
for (let i = 0; i < targetArity; i++) {
|
|
64975
65033
|
inferFromTypes(getTypeArguments(source)[i], elementTypes[i]);
|
|
64976
65034
|
}
|
|
@@ -66208,7 +66266,7 @@ function createTypeChecker(host) {
|
|
|
66208
66266
|
case 80 /* Identifier */:
|
|
66209
66267
|
if (!isThisInTypeQuery(node)) {
|
|
66210
66268
|
const symbol = getResolvedSymbol(node);
|
|
66211
|
-
return isConstantVariable(symbol) ||
|
|
66269
|
+
return isConstantVariable(symbol) || isParameterOrMutableLocalVariable(symbol) && !isSymbolAssigned(symbol);
|
|
66212
66270
|
}
|
|
66213
66271
|
break;
|
|
66214
66272
|
case 211 /* PropertyAccessExpression */:
|
|
@@ -66217,7 +66275,7 @@ function createTypeChecker(host) {
|
|
|
66217
66275
|
case 206 /* ObjectBindingPattern */:
|
|
66218
66276
|
case 207 /* ArrayBindingPattern */:
|
|
66219
66277
|
const rootDeclaration = getRootDeclaration(node.parent);
|
|
66220
|
-
return isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
|
|
66278
|
+
return isParameter(rootDeclaration) || isCatchClauseVariableDeclaration(rootDeclaration) ? !isSomeSymbolAssigned(rootDeclaration) : isVariableDeclaration(rootDeclaration) && isVarConstLike(rootDeclaration);
|
|
66221
66279
|
}
|
|
66222
66280
|
return false;
|
|
66223
66281
|
}
|
|
@@ -67298,10 +67356,17 @@ function createTypeChecker(host) {
|
|
|
67298
67356
|
return findAncestor(node.parent, (node2) => isFunctionLike(node2) && !getImmediatelyInvokedFunctionExpression(node2) || node2.kind === 268 /* ModuleBlock */ || node2.kind === 312 /* SourceFile */ || node2.kind === 172 /* PropertyDeclaration */);
|
|
67299
67357
|
}
|
|
67300
67358
|
function isSymbolAssigned(symbol) {
|
|
67301
|
-
|
|
67359
|
+
return !isPastLastAssignment(
|
|
67360
|
+
symbol,
|
|
67361
|
+
/*location*/
|
|
67362
|
+
void 0
|
|
67363
|
+
);
|
|
67364
|
+
}
|
|
67365
|
+
function isPastLastAssignment(symbol, location) {
|
|
67366
|
+
const parent = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
|
|
67367
|
+
if (!parent) {
|
|
67302
67368
|
return false;
|
|
67303
67369
|
}
|
|
67304
|
-
const parent = getRootDeclaration(symbol.valueDeclaration).parent;
|
|
67305
67370
|
const links = getNodeLinks(parent);
|
|
67306
67371
|
if (!(links.flags & 131072 /* AssignmentsMarked */)) {
|
|
67307
67372
|
links.flags |= 131072 /* AssignmentsMarked */;
|
|
@@ -67309,7 +67374,7 @@ function createTypeChecker(host) {
|
|
|
67309
67374
|
markNodeAssignments(parent);
|
|
67310
67375
|
}
|
|
67311
67376
|
}
|
|
67312
|
-
return symbol.
|
|
67377
|
+
return !symbol.lastAssignmentPos || location && symbol.lastAssignmentPos < location.pos;
|
|
67313
67378
|
}
|
|
67314
67379
|
function isSomeSymbolAssigned(rootDeclaration) {
|
|
67315
67380
|
Debug.assert(isVariableDeclaration(rootDeclaration) || isParameter(rootDeclaration));
|
|
@@ -67322,23 +67387,81 @@ function createTypeChecker(host) {
|
|
|
67322
67387
|
return some(node.elements, (e) => e.kind !== 232 /* OmittedExpression */ && isSomeSymbolAssignedWorker(e.name));
|
|
67323
67388
|
}
|
|
67324
67389
|
function hasParentWithAssignmentsMarked(node) {
|
|
67325
|
-
return !!findAncestor(node.parent, (node2) => (
|
|
67390
|
+
return !!findAncestor(node.parent, (node2) => isFunctionOrSourceFile(node2) && !!(getNodeLinks(node2).flags & 131072 /* AssignmentsMarked */));
|
|
67391
|
+
}
|
|
67392
|
+
function isFunctionOrSourceFile(node) {
|
|
67393
|
+
return isFunctionLikeDeclaration(node) || isSourceFile(node);
|
|
67326
67394
|
}
|
|
67327
67395
|
function markNodeAssignments(node) {
|
|
67328
|
-
|
|
67329
|
-
|
|
67330
|
-
|
|
67331
|
-
|
|
67332
|
-
symbol.
|
|
67396
|
+
switch (node.kind) {
|
|
67397
|
+
case 80 /* Identifier */:
|
|
67398
|
+
if (isAssignmentTarget(node)) {
|
|
67399
|
+
const symbol = getResolvedSymbol(node);
|
|
67400
|
+
if (isParameterOrMutableLocalVariable(symbol) && symbol.lastAssignmentPos !== Number.MAX_VALUE) {
|
|
67401
|
+
const referencingFunction = findAncestor(node, isFunctionOrSourceFile);
|
|
67402
|
+
const declaringFunction = findAncestor(symbol.valueDeclaration, isFunctionOrSourceFile);
|
|
67403
|
+
symbol.lastAssignmentPos = referencingFunction === declaringFunction ? extendAssignmentPosition(node, symbol.valueDeclaration) : Number.MAX_VALUE;
|
|
67404
|
+
}
|
|
67333
67405
|
}
|
|
67406
|
+
return;
|
|
67407
|
+
case 281 /* ExportSpecifier */:
|
|
67408
|
+
const exportDeclaration = node.parent.parent;
|
|
67409
|
+
if (!node.isTypeOnly && !exportDeclaration.isTypeOnly && !exportDeclaration.moduleSpecifier) {
|
|
67410
|
+
const symbol = resolveEntityName(
|
|
67411
|
+
node.propertyName || node.name,
|
|
67412
|
+
111551 /* Value */,
|
|
67413
|
+
/*ignoreErrors*/
|
|
67414
|
+
true,
|
|
67415
|
+
/*dontResolveAlias*/
|
|
67416
|
+
true
|
|
67417
|
+
);
|
|
67418
|
+
if (symbol && isParameterOrMutableLocalVariable(symbol)) {
|
|
67419
|
+
symbol.lastAssignmentPos = Number.MAX_VALUE;
|
|
67420
|
+
}
|
|
67421
|
+
}
|
|
67422
|
+
return;
|
|
67423
|
+
case 264 /* InterfaceDeclaration */:
|
|
67424
|
+
case 265 /* TypeAliasDeclaration */:
|
|
67425
|
+
case 266 /* EnumDeclaration */:
|
|
67426
|
+
return;
|
|
67427
|
+
}
|
|
67428
|
+
if (isTypeNode(node)) {
|
|
67429
|
+
return;
|
|
67430
|
+
}
|
|
67431
|
+
forEachChild(node, markNodeAssignments);
|
|
67432
|
+
}
|
|
67433
|
+
function extendAssignmentPosition(node, declaration) {
|
|
67434
|
+
let pos = node.pos;
|
|
67435
|
+
while (node && node.pos > declaration.pos) {
|
|
67436
|
+
switch (node.kind) {
|
|
67437
|
+
case 243 /* VariableStatement */:
|
|
67438
|
+
case 244 /* ExpressionStatement */:
|
|
67439
|
+
case 245 /* IfStatement */:
|
|
67440
|
+
case 246 /* DoStatement */:
|
|
67441
|
+
case 247 /* WhileStatement */:
|
|
67442
|
+
case 248 /* ForStatement */:
|
|
67443
|
+
case 249 /* ForInStatement */:
|
|
67444
|
+
case 250 /* ForOfStatement */:
|
|
67445
|
+
case 254 /* WithStatement */:
|
|
67446
|
+
case 255 /* SwitchStatement */:
|
|
67447
|
+
case 258 /* TryStatement */:
|
|
67448
|
+
case 263 /* ClassDeclaration */:
|
|
67449
|
+
pos = node.end;
|
|
67334
67450
|
}
|
|
67335
|
-
|
|
67336
|
-
forEachChild(node, markNodeAssignments);
|
|
67451
|
+
node = node.parent;
|
|
67337
67452
|
}
|
|
67453
|
+
return pos;
|
|
67338
67454
|
}
|
|
67339
67455
|
function isConstantVariable(symbol) {
|
|
67340
67456
|
return symbol.flags & 3 /* Variable */ && (getDeclarationNodeFlagsFromSymbol(symbol) & 6 /* Constant */) !== 0;
|
|
67341
67457
|
}
|
|
67458
|
+
function isParameterOrMutableLocalVariable(symbol) {
|
|
67459
|
+
const declaration = symbol.valueDeclaration && getRootDeclaration(symbol.valueDeclaration);
|
|
67460
|
+
return !!declaration && (isParameter(declaration) || isVariableDeclaration(declaration) && (isCatchClause(declaration.parent) || isMutableLocalVariableDeclaration(declaration)));
|
|
67461
|
+
}
|
|
67462
|
+
function isMutableLocalVariableDeclaration(declaration) {
|
|
67463
|
+
return !!(declaration.parent.flags & 1 /* Let */) && !(getCombinedModifierFlags(declaration) & 32 /* Export */ || declaration.parent.parent.kind === 243 /* VariableStatement */ && isGlobalSourceFile(declaration.parent.parent.parent));
|
|
67464
|
+
}
|
|
67342
67465
|
function parameterInitializerContainsUndefined(declaration) {
|
|
67343
67466
|
const links = getNodeLinks(declaration);
|
|
67344
67467
|
if (links.parameterInitializerContainsUndefined === void 0) {
|
|
@@ -67587,7 +67710,7 @@ function createTypeChecker(host) {
|
|
|
67587
67710
|
const isModuleExports = symbol.flags & 134217728 /* ModuleExports */;
|
|
67588
67711
|
const typeIsAutomatic = type === autoType || type === autoArrayType;
|
|
67589
67712
|
const isAutomaticTypeInNonNull = typeIsAutomatic && node.parent.kind === 235 /* NonNullExpression */;
|
|
67590
|
-
while (flowContainer !== declarationContainer && (flowContainer.kind === 218 /* FunctionExpression */ || flowContainer.kind === 219 /* ArrowFunction */ || isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstantVariable(localOrExportSymbol) && type !== autoArrayType ||
|
|
67713
|
+
while (flowContainer !== declarationContainer && (flowContainer.kind === 218 /* FunctionExpression */ || flowContainer.kind === 219 /* ArrowFunction */ || isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && (isConstantVariable(localOrExportSymbol) && type !== autoArrayType || isParameterOrMutableLocalVariable(localOrExportSymbol) && isPastLastAssignment(localOrExportSymbol, node))) {
|
|
67591
67714
|
flowContainer = getControlFlowContainer(flowContainer);
|
|
67592
67715
|
}
|
|
67593
67716
|
const assumeInitialized = isParameter2 || isAlias || isOuterVariable || isSpreadDestructuringAssignmentTarget || isModuleExports || isSameScopedBindingElement(node, declaration) || type !== autoType && type !== autoArrayType && (!strictNullChecks || (type.flags & (3 /* AnyOrUnknown */ | 16384 /* Void */)) !== 0 || isInTypeQuery(node) || isInAmbientOrTypeNode(node) || node.parent.kind === 281 /* ExportSpecifier */) || node.parent.kind === 235 /* NonNullExpression */ || declaration.kind === 260 /* VariableDeclaration */ && declaration.exclamationToken || declaration.flags & 33554432 /* Ambient */;
|
|
@@ -68858,8 +68981,6 @@ function createTypeChecker(host) {
|
|
|
68858
68981
|
case 286 /* JsxOpeningElement */:
|
|
68859
68982
|
case 285 /* JsxSelfClosingElement */:
|
|
68860
68983
|
return getContextualJsxElementAttributesType(parent, contextFlags);
|
|
68861
|
-
case 301 /* ImportAttribute */:
|
|
68862
|
-
return getContextualImportAttributeType(parent);
|
|
68863
68984
|
}
|
|
68864
68985
|
return void 0;
|
|
68865
68986
|
}
|
|
@@ -68907,12 +69028,6 @@ function createTypeChecker(host) {
|
|
|
68907
69028
|
}
|
|
68908
69029
|
}
|
|
68909
69030
|
}
|
|
68910
|
-
function getContextualImportAttributeType(node) {
|
|
68911
|
-
return getTypeOfPropertyOfContextualType(getGlobalImportAttributesType(
|
|
68912
|
-
/*reportErrors*/
|
|
68913
|
-
false
|
|
68914
|
-
), getNameFromImportAttribute(node));
|
|
68915
|
-
}
|
|
68916
69031
|
function getContextualJsxElementAttributesType(node, contextFlags) {
|
|
68917
69032
|
if (isJsxOpeningElement(node) && contextFlags !== 4 /* Completions */) {
|
|
68918
69033
|
const index = findContextualNode(
|
|
@@ -80998,13 +81113,6 @@ function createTypeChecker(host) {
|
|
|
80998
81113
|
var _a;
|
|
80999
81114
|
const node = declaration.attributes;
|
|
81000
81115
|
if (node) {
|
|
81001
|
-
const importAttributesType = getGlobalImportAttributesType(
|
|
81002
|
-
/*reportErrors*/
|
|
81003
|
-
true
|
|
81004
|
-
);
|
|
81005
|
-
if (importAttributesType !== emptyObjectType) {
|
|
81006
|
-
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 32768 /* Undefined */), node);
|
|
81007
|
-
}
|
|
81008
81116
|
const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
81009
81117
|
const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
|
|
81010
81118
|
const isImportAttributes2 = declaration.attributes.token === 118 /* WithKeyword */;
|
|
@@ -81024,9 +81132,6 @@ function createTypeChecker(host) {
|
|
|
81024
81132
|
}
|
|
81025
81133
|
}
|
|
81026
81134
|
}
|
|
81027
|
-
function checkImportAttribute(node) {
|
|
81028
|
-
return getRegularTypeOfLiteralType(checkExpressionCached(node.value));
|
|
81029
|
-
}
|
|
81030
81135
|
function checkImportDeclaration(node) {
|
|
81031
81136
|
if (checkGrammarModuleElementContext(node, isInJSFile(node) ? Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_module : Diagnostics.An_import_declaration_can_only_be_used_at_the_top_level_of_a_namespace_or_module)) {
|
|
81032
81137
|
return;
|
|
@@ -82442,12 +82547,6 @@ function createTypeChecker(host) {
|
|
|
82442
82547
|
if (isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
|
|
82443
82548
|
return checkMetaPropertyKeyword(node.parent);
|
|
82444
82549
|
}
|
|
82445
|
-
if (isImportAttributes(node)) {
|
|
82446
|
-
return getGlobalImportAttributesType(
|
|
82447
|
-
/*reportErrors*/
|
|
82448
|
-
false
|
|
82449
|
-
);
|
|
82450
|
-
}
|
|
82451
82550
|
return errorType;
|
|
82452
82551
|
}
|
|
82453
82552
|
function getTypeOfAssignmentPattern(expr) {
|
|
@@ -113470,7 +113569,14 @@ function createPrinter(printerOptions = {}, handlers = {}) {
|
|
|
113470
113569
|
function willEmitLeadingNewLine(node) {
|
|
113471
113570
|
if (!currentSourceFile)
|
|
113472
113571
|
return false;
|
|
113473
|
-
|
|
113572
|
+
const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
|
113573
|
+
if (leadingCommentRanges) {
|
|
113574
|
+
const parseNode = getParseTreeNode(node);
|
|
113575
|
+
if (parseNode && isParenthesizedExpression(parseNode.parent)) {
|
|
113576
|
+
return true;
|
|
113577
|
+
}
|
|
113578
|
+
}
|
|
113579
|
+
if (some(leadingCommentRanges, commentWillEmitNewLine))
|
|
113474
113580
|
return true;
|
|
113475
113581
|
if (some(getSyntheticLeadingComments(node), commentWillEmitNewLine))
|
|
113476
113582
|
return true;
|