typescript 5.4.0-dev.20240109 → 5.4.0-dev.20240111
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 +181 -55
- package/lib/tsserver.js +259 -79
- package/lib/typescript.d.ts +9 -0
- package/lib/typescript.js +258 -79
- package/lib/typingsInstaller.js +1 -1
- 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.4";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20240111`;
|
|
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) {
|
|
@@ -17668,6 +17671,9 @@ var stringReplace = String.prototype.replace;
|
|
|
17668
17671
|
function replaceFirstStar(s, replacement) {
|
|
17669
17672
|
return stringReplace.call(s, "*", replacement);
|
|
17670
17673
|
}
|
|
17674
|
+
function getNameFromImportAttribute(node) {
|
|
17675
|
+
return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
|
|
17676
|
+
}
|
|
17671
17677
|
|
|
17672
17678
|
// src/compiler/factory/baseNodeFactory.ts
|
|
17673
17679
|
function createBaseNodeFactory() {
|
|
@@ -44281,6 +44287,14 @@ function createTypeChecker(host) {
|
|
|
44281
44287
|
emptyArray,
|
|
44282
44288
|
emptyArray
|
|
44283
44289
|
);
|
|
44290
|
+
var resolvingApparentMappedType = createAnonymousType(
|
|
44291
|
+
/*symbol*/
|
|
44292
|
+
void 0,
|
|
44293
|
+
emptySymbols,
|
|
44294
|
+
emptyArray,
|
|
44295
|
+
emptyArray,
|
|
44296
|
+
emptyArray
|
|
44297
|
+
);
|
|
44284
44298
|
var markerSuperType = createTypeParameter();
|
|
44285
44299
|
var markerSubType = createTypeParameter();
|
|
44286
44300
|
markerSubType.constraint = markerSuperType;
|
|
@@ -44435,6 +44449,7 @@ function createTypeChecker(host) {
|
|
|
44435
44449
|
var deferredGlobalImportMetaType;
|
|
44436
44450
|
var deferredGlobalImportMetaExpressionType;
|
|
44437
44451
|
var deferredGlobalImportCallOptionsType;
|
|
44452
|
+
var deferredGlobalImportAttributesType;
|
|
44438
44453
|
var deferredGlobalDisposableType;
|
|
44439
44454
|
var deferredGlobalAsyncDisposableType;
|
|
44440
44455
|
var deferredGlobalExtractSymbol;
|
|
@@ -47330,29 +47345,7 @@ function createTypeChecker(host) {
|
|
|
47330
47345
|
function getContainersOfSymbol(symbol, enclosingDeclaration, meaning) {
|
|
47331
47346
|
const container = getParentOfSymbol(symbol);
|
|
47332
47347
|
if (container && !(symbol.flags & 262144 /* TypeParameter */)) {
|
|
47333
|
-
|
|
47334
|
-
const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
|
|
47335
|
-
const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container, meaning);
|
|
47336
|
-
if (enclosingDeclaration && container.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
|
|
47337
|
-
container,
|
|
47338
|
-
enclosingDeclaration,
|
|
47339
|
-
1920 /* Namespace */,
|
|
47340
|
-
/*useOnlyExternalAliasing*/
|
|
47341
|
-
false
|
|
47342
|
-
)) {
|
|
47343
|
-
return append(concatenate(concatenate([container], additionalContainers), reexportContainers), objectLiteralContainer);
|
|
47344
|
-
}
|
|
47345
|
-
const firstVariableMatch = !(container.flags & getQualifiedLeftMeaning(meaning)) && container.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
|
|
47346
|
-
return forEachEntry(t, (s) => {
|
|
47347
|
-
if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container)) {
|
|
47348
|
-
return s;
|
|
47349
|
-
}
|
|
47350
|
-
});
|
|
47351
|
-
}) : void 0;
|
|
47352
|
-
let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container] : [...additionalContainers, container];
|
|
47353
|
-
res = append(res, objectLiteralContainer);
|
|
47354
|
-
res = addRange(res, reexportContainers);
|
|
47355
|
-
return res;
|
|
47348
|
+
return getWithAlternativeContainers(container);
|
|
47356
47349
|
}
|
|
47357
47350
|
const candidates = mapDefined(symbol.declarations, (d) => {
|
|
47358
47351
|
if (!isAmbientModule(d) && d.parent) {
|
|
@@ -47374,7 +47367,40 @@ function createTypeChecker(host) {
|
|
|
47374
47367
|
if (!length(candidates)) {
|
|
47375
47368
|
return void 0;
|
|
47376
47369
|
}
|
|
47377
|
-
|
|
47370
|
+
const containers = mapDefined(candidates, (candidate) => getAliasForSymbolInContainer(candidate, symbol) ? candidate : void 0);
|
|
47371
|
+
let bestContainers = [];
|
|
47372
|
+
let alternativeContainers = [];
|
|
47373
|
+
for (const container2 of containers) {
|
|
47374
|
+
const [bestMatch, ...rest] = getWithAlternativeContainers(container2);
|
|
47375
|
+
bestContainers = append(bestContainers, bestMatch);
|
|
47376
|
+
alternativeContainers = addRange(alternativeContainers, rest);
|
|
47377
|
+
}
|
|
47378
|
+
return concatenate(bestContainers, alternativeContainers);
|
|
47379
|
+
function getWithAlternativeContainers(container2) {
|
|
47380
|
+
const additionalContainers = mapDefined(container2.declarations, fileSymbolIfFileSymbolExportEqualsContainer);
|
|
47381
|
+
const reexportContainers = enclosingDeclaration && getAlternativeContainingModules(symbol, enclosingDeclaration);
|
|
47382
|
+
const objectLiteralContainer = getVariableDeclarationOfObjectLiteral(container2, meaning);
|
|
47383
|
+
if (enclosingDeclaration && container2.flags & getQualifiedLeftMeaning(meaning) && getAccessibleSymbolChain(
|
|
47384
|
+
container2,
|
|
47385
|
+
enclosingDeclaration,
|
|
47386
|
+
1920 /* Namespace */,
|
|
47387
|
+
/*useOnlyExternalAliasing*/
|
|
47388
|
+
false
|
|
47389
|
+
)) {
|
|
47390
|
+
return append(concatenate(concatenate([container2], additionalContainers), reexportContainers), objectLiteralContainer);
|
|
47391
|
+
}
|
|
47392
|
+
const firstVariableMatch = !(container2.flags & getQualifiedLeftMeaning(meaning)) && container2.flags & 788968 /* Type */ && getDeclaredTypeOfSymbol(container2).flags & 524288 /* Object */ && meaning === 111551 /* Value */ ? forEachSymbolTableInScope(enclosingDeclaration, (t) => {
|
|
47393
|
+
return forEachEntry(t, (s) => {
|
|
47394
|
+
if (s.flags & getQualifiedLeftMeaning(meaning) && getTypeOfSymbol(s) === getDeclaredTypeOfSymbol(container2)) {
|
|
47395
|
+
return s;
|
|
47396
|
+
}
|
|
47397
|
+
});
|
|
47398
|
+
}) : void 0;
|
|
47399
|
+
let res = firstVariableMatch ? [firstVariableMatch, ...additionalContainers, container2] : [...additionalContainers, container2];
|
|
47400
|
+
res = append(res, objectLiteralContainer);
|
|
47401
|
+
res = addRange(res, reexportContainers);
|
|
47402
|
+
return res;
|
|
47403
|
+
}
|
|
47378
47404
|
function fileSymbolIfFileSymbolExportEqualsContainer(d) {
|
|
47379
47405
|
return container && getFileSymbolIfFileSymbolExportEqualsContainer(d, container);
|
|
47380
47406
|
}
|
|
@@ -47412,6 +47438,13 @@ function createTypeChecker(host) {
|
|
|
47412
47438
|
});
|
|
47413
47439
|
}
|
|
47414
47440
|
function getSymbolIfSameReference(s1, s2) {
|
|
47441
|
+
var _a, _b;
|
|
47442
|
+
if (s1.flags & 524288 /* TypeAlias */ && ((_a = s2.declarations) == null ? void 0 : _a.find(isTypeAlias))) {
|
|
47443
|
+
s2 = getDeclaredTypeOfTypeAlias(s2).aliasSymbol || s2;
|
|
47444
|
+
}
|
|
47445
|
+
if (s2.flags & 524288 /* TypeAlias */ && ((_b = s1.declarations) == null ? void 0 : _b.find(isTypeAlias))) {
|
|
47446
|
+
s1 = getDeclaredTypeOfTypeAlias(s1).aliasSymbol || s1;
|
|
47447
|
+
}
|
|
47415
47448
|
if (getMergedSymbol(resolveSymbol(getMergedSymbol(s1))) === getMergedSymbol(resolveSymbol(getMergedSymbol(s2)))) {
|
|
47416
47449
|
return s1;
|
|
47417
47450
|
}
|
|
@@ -52654,7 +52687,7 @@ function createTypeChecker(host) {
|
|
|
52654
52687
|
/*reportErrors*/
|
|
52655
52688
|
false
|
|
52656
52689
|
) : unknownType;
|
|
52657
|
-
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, 0 /* Normal */, contextualType)));
|
|
52690
|
+
return addOptionality(widenTypeInferredFromInitializer(element, checkDeclarationInitializer(element, reportErrors2 ? 0 /* Normal */ : 1 /* Contextual */, contextualType)));
|
|
52658
52691
|
}
|
|
52659
52692
|
if (isBindingPattern(element.name)) {
|
|
52660
52693
|
return getTypeFromBindingPattern(element.name, includePatternInType, reportErrors2);
|
|
@@ -52735,6 +52768,24 @@ function createTypeChecker(host) {
|
|
|
52735
52768
|
0 /* Normal */
|
|
52736
52769
|
), declaration, reportErrors2);
|
|
52737
52770
|
}
|
|
52771
|
+
function getTypeFromImportAttributes(node) {
|
|
52772
|
+
const links = getNodeLinks(node);
|
|
52773
|
+
if (!links.resolvedType) {
|
|
52774
|
+
const symbol = createSymbol(4096 /* ObjectLiteral */, "__importAttributes" /* ImportAttributes */);
|
|
52775
|
+
const members = createSymbolTable();
|
|
52776
|
+
forEach(node.elements, (attr) => {
|
|
52777
|
+
const member = createSymbol(4 /* Property */, getNameFromImportAttribute(attr));
|
|
52778
|
+
member.parent = symbol;
|
|
52779
|
+
member.links.type = checkImportAttribute(attr);
|
|
52780
|
+
member.links.target = member;
|
|
52781
|
+
members.set(member.escapedName, member);
|
|
52782
|
+
});
|
|
52783
|
+
const type = createAnonymousType(symbol, members, emptyArray, emptyArray, emptyArray);
|
|
52784
|
+
type.objectFlags |= 128 /* ObjectLiteral */ | 262144 /* NonInferrableType */;
|
|
52785
|
+
links.resolvedType = type;
|
|
52786
|
+
}
|
|
52787
|
+
return links.resolvedType;
|
|
52788
|
+
}
|
|
52738
52789
|
function isGlobalSymbolConstructor(node) {
|
|
52739
52790
|
const symbol = getSymbolOfNode(node);
|
|
52740
52791
|
const globalSymbol = getGlobalESSymbolConstructorTypeSymbol(
|
|
@@ -52788,18 +52839,18 @@ function createTypeChecker(host) {
|
|
|
52788
52839
|
}
|
|
52789
52840
|
return false;
|
|
52790
52841
|
}
|
|
52791
|
-
function getTypeOfVariableOrParameterOrProperty(symbol) {
|
|
52842
|
+
function getTypeOfVariableOrParameterOrProperty(symbol, checkMode) {
|
|
52792
52843
|
const links = getSymbolLinks(symbol);
|
|
52793
52844
|
if (!links.type) {
|
|
52794
|
-
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
|
|
52795
|
-
if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
|
|
52845
|
+
const type = getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode);
|
|
52846
|
+
if (!links.type && !isParameterOfContextSensitiveSignature(symbol) && !checkMode) {
|
|
52796
52847
|
links.type = type;
|
|
52797
52848
|
}
|
|
52798
52849
|
return type;
|
|
52799
52850
|
}
|
|
52800
52851
|
return links.type;
|
|
52801
52852
|
}
|
|
52802
|
-
function getTypeOfVariableOrParameterOrPropertyWorker(symbol) {
|
|
52853
|
+
function getTypeOfVariableOrParameterOrPropertyWorker(symbol, checkMode) {
|
|
52803
52854
|
if (symbol.flags & 4194304 /* Prototype */) {
|
|
52804
52855
|
return getTypeOfPrototypeProperty(symbol);
|
|
52805
52856
|
}
|
|
@@ -52837,6 +52888,9 @@ function createTypeChecker(host) {
|
|
|
52837
52888
|
if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
|
|
52838
52889
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
52839
52890
|
}
|
|
52891
|
+
if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
|
|
52892
|
+
return errorType;
|
|
52893
|
+
}
|
|
52840
52894
|
return reportCircularityError(symbol);
|
|
52841
52895
|
}
|
|
52842
52896
|
let type;
|
|
@@ -52874,6 +52928,9 @@ function createTypeChecker(host) {
|
|
|
52874
52928
|
if (symbol.flags & 512 /* ValueModule */ && !(symbol.flags & 67108864 /* Assignment */)) {
|
|
52875
52929
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
52876
52930
|
}
|
|
52931
|
+
if (isBindingElement(declaration) && checkMode === 1 /* Contextual */) {
|
|
52932
|
+
return type;
|
|
52933
|
+
}
|
|
52877
52934
|
return reportCircularityError(symbol);
|
|
52878
52935
|
}
|
|
52879
52936
|
return type;
|
|
@@ -53102,7 +53159,7 @@ function createTypeChecker(host) {
|
|
|
53102
53159
|
}
|
|
53103
53160
|
return getTypeOfSymbol(symbol);
|
|
53104
53161
|
}
|
|
53105
|
-
function getTypeOfSymbol(symbol) {
|
|
53162
|
+
function getTypeOfSymbol(symbol, checkMode) {
|
|
53106
53163
|
const checkFlags = getCheckFlags(symbol);
|
|
53107
53164
|
if (checkFlags & 65536 /* DeferredType */) {
|
|
53108
53165
|
return getTypeOfSymbolWithDeferredType(symbol);
|
|
@@ -53117,7 +53174,7 @@ function createTypeChecker(host) {
|
|
|
53117
53174
|
return getTypeOfReverseMappedSymbol(symbol);
|
|
53118
53175
|
}
|
|
53119
53176
|
if (symbol.flags & (3 /* Variable */ | 4 /* Property */)) {
|
|
53120
|
-
return getTypeOfVariableOrParameterOrProperty(symbol);
|
|
53177
|
+
return getTypeOfVariableOrParameterOrProperty(symbol, checkMode);
|
|
53121
53178
|
}
|
|
53122
53179
|
if (symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 384 /* Enum */ | 512 /* ValueModule */)) {
|
|
53123
53180
|
return getTypeOfFuncClassEnumModule(symbol);
|
|
@@ -55150,14 +55207,30 @@ function createTypeChecker(host) {
|
|
|
55150
55207
|
return !!(typeParameter.symbol && forEach(typeParameter.symbol.declarations, (decl) => isTypeParameterDeclaration(decl) && decl.default));
|
|
55151
55208
|
}
|
|
55152
55209
|
function getApparentTypeOfMappedType(type) {
|
|
55153
|
-
|
|
55210
|
+
if (type.resolvedApparentType) {
|
|
55211
|
+
if (type.resolvedApparentType === resolvingApparentMappedType) {
|
|
55212
|
+
return type.resolvedApparentType = type;
|
|
55213
|
+
}
|
|
55214
|
+
return type.resolvedApparentType;
|
|
55215
|
+
}
|
|
55216
|
+
type.resolvedApparentType = resolvingApparentMappedType;
|
|
55217
|
+
return type.resolvedApparentType = getResolvedApparentTypeOfMappedType(type);
|
|
55154
55218
|
}
|
|
55155
55219
|
function getResolvedApparentTypeOfMappedType(type) {
|
|
55156
|
-
const
|
|
55157
|
-
|
|
55158
|
-
|
|
55220
|
+
const mappedType = type.target || type;
|
|
55221
|
+
const typeVariable = getHomomorphicTypeVariable(mappedType);
|
|
55222
|
+
if (typeVariable && !mappedType.declaration.nameType) {
|
|
55223
|
+
let constraint;
|
|
55224
|
+
if (!type.target) {
|
|
55225
|
+
constraint = getConstraintOfTypeParameter(typeVariable);
|
|
55226
|
+
} else {
|
|
55227
|
+
const modifiersConstraint = getConstraintOfType(getModifiersTypeFromMappedType(type));
|
|
55228
|
+
if (modifiersConstraint) {
|
|
55229
|
+
constraint = getApparentType(modifiersConstraint);
|
|
55230
|
+
}
|
|
55231
|
+
}
|
|
55159
55232
|
if (constraint && everyType(constraint, isArrayOrTupleType)) {
|
|
55160
|
-
return instantiateType(
|
|
55233
|
+
return instantiateType(mappedType, prependTypeMapping(typeVariable, constraint, mappedType.mapper));
|
|
55161
55234
|
}
|
|
55162
55235
|
}
|
|
55163
55236
|
return type;
|
|
@@ -55248,6 +55321,7 @@ function createTypeChecker(host) {
|
|
|
55248
55321
|
clone2.parent = (_c = (_b = singleProp.valueDeclaration) == null ? void 0 : _b.symbol) == null ? void 0 : _c.parent;
|
|
55249
55322
|
clone2.links.containingType = containingType;
|
|
55250
55323
|
clone2.links.mapper = links == null ? void 0 : links.mapper;
|
|
55324
|
+
clone2.links.writeType = getWriteTypeOfSymbol(singleProp);
|
|
55251
55325
|
return clone2;
|
|
55252
55326
|
} else {
|
|
55253
55327
|
return singleProp;
|
|
@@ -56716,6 +56790,14 @@ function createTypeChecker(host) {
|
|
|
56716
56790
|
reportErrors2
|
|
56717
56791
|
)) || emptyObjectType;
|
|
56718
56792
|
}
|
|
56793
|
+
function getGlobalImportAttributesType(reportErrors2) {
|
|
56794
|
+
return deferredGlobalImportAttributesType || (deferredGlobalImportAttributesType = getGlobalType(
|
|
56795
|
+
"ImportAttributes",
|
|
56796
|
+
/*arity*/
|
|
56797
|
+
0,
|
|
56798
|
+
reportErrors2
|
|
56799
|
+
)) || emptyObjectType;
|
|
56800
|
+
}
|
|
56719
56801
|
function getGlobalESSymbolConstructorSymbol(reportErrors2) {
|
|
56720
56802
|
return deferredGlobalESSymbolConstructorSymbol || (deferredGlobalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol", reportErrors2));
|
|
56721
56803
|
}
|
|
@@ -61873,6 +61955,18 @@ function createTypeChecker(host) {
|
|
|
61873
61955
|
}
|
|
61874
61956
|
return result2;
|
|
61875
61957
|
}
|
|
61958
|
+
function getApparentMappedTypeKeys(nameType, targetType) {
|
|
61959
|
+
const modifiersType = getApparentType(getModifiersTypeFromMappedType(targetType));
|
|
61960
|
+
const mappedKeys = [];
|
|
61961
|
+
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
61962
|
+
modifiersType,
|
|
61963
|
+
8576 /* StringOrNumberLiteralOrUnique */,
|
|
61964
|
+
/*stringsOnly*/
|
|
61965
|
+
false,
|
|
61966
|
+
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
61967
|
+
);
|
|
61968
|
+
return getUnionType(mappedKeys);
|
|
61969
|
+
}
|
|
61876
61970
|
function structuredTypeRelatedToWorker(source2, target2, reportErrors2, intersectionState, saveErrorInfo) {
|
|
61877
61971
|
let result2;
|
|
61878
61972
|
let originalErrorInfo;
|
|
@@ -62055,16 +62149,8 @@ function createTypeChecker(host) {
|
|
|
62055
62149
|
const constraintType = getConstraintTypeFromMappedType(targetType);
|
|
62056
62150
|
let targetKeys;
|
|
62057
62151
|
if (nameType && isMappedTypeWithKeyofConstraintDeclaration(targetType)) {
|
|
62058
|
-
const
|
|
62059
|
-
|
|
62060
|
-
forEachMappedTypePropertyKeyTypeAndIndexSignatureKeyType(
|
|
62061
|
-
modifiersType,
|
|
62062
|
-
8576 /* StringOrNumberLiteralOrUnique */,
|
|
62063
|
-
/*stringsOnly*/
|
|
62064
|
-
false,
|
|
62065
|
-
(t) => void mappedKeys.push(instantiateType(nameType, appendTypeMapping(targetType.mapper, getTypeParameterFromMappedType(targetType), t)))
|
|
62066
|
-
);
|
|
62067
|
-
targetKeys = getUnionType([...mappedKeys, nameType]);
|
|
62152
|
+
const mappedKeys = getApparentMappedTypeKeys(nameType, targetType);
|
|
62153
|
+
targetKeys = getUnionType([mappedKeys, nameType]);
|
|
62068
62154
|
} else {
|
|
62069
62155
|
targetKeys = nameType || constraintType;
|
|
62070
62156
|
}
|
|
@@ -62235,9 +62321,18 @@ function createTypeChecker(host) {
|
|
|
62235
62321
|
}
|
|
62236
62322
|
}
|
|
62237
62323
|
} else if (sourceFlags & 4194304 /* Index */) {
|
|
62238
|
-
|
|
62324
|
+
const isDeferredMappedIndex = shouldDeferIndexType(source2.type, source2.indexFlags) && getObjectFlags(source2.type) & 32 /* Mapped */;
|
|
62325
|
+
if (result2 = isRelatedTo(keyofConstraintType, target2, 1 /* Source */, reportErrors2 && !isDeferredMappedIndex)) {
|
|
62239
62326
|
return result2;
|
|
62240
62327
|
}
|
|
62328
|
+
if (isDeferredMappedIndex) {
|
|
62329
|
+
const mappedType = source2.type;
|
|
62330
|
+
const nameType = getNameTypeFromMappedType(mappedType);
|
|
62331
|
+
const sourceMappedKeys = nameType && isMappedTypeWithKeyofConstraintDeclaration(mappedType) ? getApparentMappedTypeKeys(nameType, mappedType) : nameType || getConstraintTypeFromMappedType(mappedType);
|
|
62332
|
+
if (result2 = isRelatedTo(sourceMappedKeys, target2, 1 /* Source */, reportErrors2)) {
|
|
62333
|
+
return result2;
|
|
62334
|
+
}
|
|
62335
|
+
}
|
|
62241
62336
|
} else if (sourceFlags & 134217728 /* TemplateLiteral */ && !(targetFlags & 524288 /* Object */)) {
|
|
62242
62337
|
if (!(targetFlags & 134217728 /* TemplateLiteral */)) {
|
|
62243
62338
|
const constraint = getBaseConstraintOfType(source2);
|
|
@@ -67450,9 +67545,9 @@ function createTypeChecker(host) {
|
|
|
67450
67545
|
}
|
|
67451
67546
|
}
|
|
67452
67547
|
}
|
|
67453
|
-
function getNarrowedTypeOfSymbol(symbol, location) {
|
|
67548
|
+
function getNarrowedTypeOfSymbol(symbol, location, checkMode) {
|
|
67454
67549
|
var _a;
|
|
67455
|
-
const type = getTypeOfSymbol(symbol);
|
|
67550
|
+
const type = getTypeOfSymbol(symbol, checkMode);
|
|
67456
67551
|
const declaration = symbol.valueDeclaration;
|
|
67457
67552
|
if (declaration) {
|
|
67458
67553
|
if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) {
|
|
@@ -67579,7 +67674,7 @@ function createTypeChecker(host) {
|
|
|
67579
67674
|
}
|
|
67580
67675
|
}
|
|
67581
67676
|
checkNestedBlockScopedBinding(node, symbol);
|
|
67582
|
-
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node);
|
|
67677
|
+
let type = getNarrowedTypeOfSymbol(localOrExportSymbol, node, checkMode);
|
|
67583
67678
|
const assignmentKind = getAssignmentTargetKind(node);
|
|
67584
67679
|
if (assignmentKind) {
|
|
67585
67680
|
if (!(localOrExportSymbol.flags & 3 /* Variable */) && !(isInJSFile(node) && localOrExportSymbol.flags & 512 /* ValueModule */)) {
|
|
@@ -68889,6 +68984,8 @@ function createTypeChecker(host) {
|
|
|
68889
68984
|
case 286 /* JsxOpeningElement */:
|
|
68890
68985
|
case 285 /* JsxSelfClosingElement */:
|
|
68891
68986
|
return getContextualJsxElementAttributesType(parent, contextFlags);
|
|
68987
|
+
case 301 /* ImportAttribute */:
|
|
68988
|
+
return getContextualImportAttributeType(parent);
|
|
68892
68989
|
}
|
|
68893
68990
|
return void 0;
|
|
68894
68991
|
}
|
|
@@ -68936,6 +69033,12 @@ function createTypeChecker(host) {
|
|
|
68936
69033
|
}
|
|
68937
69034
|
}
|
|
68938
69035
|
}
|
|
69036
|
+
function getContextualImportAttributeType(node) {
|
|
69037
|
+
return getTypeOfPropertyOfContextualType(getGlobalImportAttributesType(
|
|
69038
|
+
/*reportErrors*/
|
|
69039
|
+
false
|
|
69040
|
+
), getNameFromImportAttribute(node));
|
|
69041
|
+
}
|
|
68939
69042
|
function getContextualJsxElementAttributesType(node, contextFlags) {
|
|
68940
69043
|
if (isJsxOpeningElement(node) && contextFlags !== 4 /* Completions */) {
|
|
68941
69044
|
const index = findContextualNode(
|
|
@@ -81021,6 +81124,13 @@ function createTypeChecker(host) {
|
|
|
81021
81124
|
var _a;
|
|
81022
81125
|
const node = declaration.attributes;
|
|
81023
81126
|
if (node) {
|
|
81127
|
+
const importAttributesType = getGlobalImportAttributesType(
|
|
81128
|
+
/*reportErrors*/
|
|
81129
|
+
true
|
|
81130
|
+
);
|
|
81131
|
+
if (importAttributesType !== emptyObjectType) {
|
|
81132
|
+
checkTypeAssignableTo(getTypeFromImportAttributes(node), getNullableType(importAttributesType, 32768 /* Undefined */), node);
|
|
81133
|
+
}
|
|
81024
81134
|
const validForTypeAttributes = isExclusivelyTypeOnlyImportOrExport(declaration);
|
|
81025
81135
|
const override = getResolutionModeOverride(node, validForTypeAttributes ? grammarErrorOnNode : void 0);
|
|
81026
81136
|
const isImportAttributes2 = declaration.attributes.token === 118 /* WithKeyword */;
|
|
@@ -81040,6 +81150,9 @@ function createTypeChecker(host) {
|
|
|
81040
81150
|
}
|
|
81041
81151
|
}
|
|
81042
81152
|
}
|
|
81153
|
+
function checkImportAttribute(node) {
|
|
81154
|
+
return getRegularTypeOfLiteralType(checkExpressionCached(node.value));
|
|
81155
|
+
}
|
|
81043
81156
|
function checkImportDeclaration(node) {
|
|
81044
81157
|
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)) {
|
|
81045
81158
|
return;
|
|
@@ -82455,6 +82568,12 @@ function createTypeChecker(host) {
|
|
|
82455
82568
|
if (isMetaProperty(node.parent) && node.parent.keywordToken === node.kind) {
|
|
82456
82569
|
return checkMetaPropertyKeyword(node.parent);
|
|
82457
82570
|
}
|
|
82571
|
+
if (isImportAttributes(node)) {
|
|
82572
|
+
return getGlobalImportAttributesType(
|
|
82573
|
+
/*reportErrors*/
|
|
82574
|
+
false
|
|
82575
|
+
);
|
|
82576
|
+
}
|
|
82458
82577
|
return errorType;
|
|
82459
82578
|
}
|
|
82460
82579
|
function getTypeOfAssignmentPattern(expr) {
|
|
@@ -113477,7 +113596,14 @@ function createPrinter(printerOptions = {}, handlers = {}) {
|
|
|
113477
113596
|
function willEmitLeadingNewLine(node) {
|
|
113478
113597
|
if (!currentSourceFile)
|
|
113479
113598
|
return false;
|
|
113480
|
-
|
|
113599
|
+
const leadingCommentRanges = getLeadingCommentRanges(currentSourceFile.text, node.pos);
|
|
113600
|
+
if (leadingCommentRanges) {
|
|
113601
|
+
const parseNode = getParseTreeNode(node);
|
|
113602
|
+
if (parseNode && isParenthesizedExpression(parseNode.parent)) {
|
|
113603
|
+
return true;
|
|
113604
|
+
}
|
|
113605
|
+
}
|
|
113606
|
+
if (some(leadingCommentRanges, commentWillEmitNewLine))
|
|
113481
113607
|
return true;
|
|
113482
113608
|
if (some(getSyntheticLeadingComments(node), commentWillEmitNewLine))
|
|
113483
113609
|
return true;
|
|
@@ -119535,7 +119661,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
119535
119661
|
}
|
|
119536
119662
|
const isFromNodeModulesSearch = resolution.isExternalLibraryImport;
|
|
119537
119663
|
const isJsFile = !resolutionExtensionIsTSOrJson(resolution.extension);
|
|
119538
|
-
const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile;
|
|
119664
|
+
const isJsFileFromNodeModules = isFromNodeModulesSearch && isJsFile && (!resolution.originalPath || pathContainsNodeModules(resolution.resolvedFileName));
|
|
119539
119665
|
const resolvedFileName = resolution.resolvedFileName;
|
|
119540
119666
|
if (isFromNodeModulesSearch) {
|
|
119541
119667
|
currentNodeModulesDepth++;
|