typescript 5.5.0-dev.20240327 → 5.5.0-dev.20240328
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/lib.es2015.core.d.ts +40 -0
- package/lib/lib.es2020.bigint.d.ts +2 -2
- package/lib/tsc.js +217 -152
- package/lib/typescript.d.ts +6 -3
- package/lib/typescript.js +251 -170
- 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.5";
|
|
21
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
21
|
+
var version = `${versionMajorMinor}.0-dev.20240328`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -3699,6 +3699,7 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
3699
3699
|
ObjectFlags3[ObjectFlags3["ContainsSpread"] = 2097152] = "ContainsSpread";
|
|
3700
3700
|
ObjectFlags3[ObjectFlags3["ObjectRestType"] = 4194304] = "ObjectRestType";
|
|
3701
3701
|
ObjectFlags3[ObjectFlags3["InstantiationExpressionType"] = 8388608] = "InstantiationExpressionType";
|
|
3702
|
+
ObjectFlags3[ObjectFlags3["SingleSignatureType"] = 134217728] = "SingleSignatureType";
|
|
3702
3703
|
ObjectFlags3[ObjectFlags3["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone";
|
|
3703
3704
|
ObjectFlags3[ObjectFlags3["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated";
|
|
3704
3705
|
ObjectFlags3[ObjectFlags3["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists";
|
|
@@ -17697,6 +17698,91 @@ function isSyntacticallyString(expr) {
|
|
|
17697
17698
|
}
|
|
17698
17699
|
return false;
|
|
17699
17700
|
}
|
|
17701
|
+
function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameExpression }) {
|
|
17702
|
+
function evaluate(expr, location) {
|
|
17703
|
+
switch (expr.kind) {
|
|
17704
|
+
case 224 /* PrefixUnaryExpression */:
|
|
17705
|
+
const value = evaluate(expr.operand, location);
|
|
17706
|
+
if (typeof value === "number") {
|
|
17707
|
+
switch (expr.operator) {
|
|
17708
|
+
case 40 /* PlusToken */:
|
|
17709
|
+
return value;
|
|
17710
|
+
case 41 /* MinusToken */:
|
|
17711
|
+
return -value;
|
|
17712
|
+
case 55 /* TildeToken */:
|
|
17713
|
+
return ~value;
|
|
17714
|
+
}
|
|
17715
|
+
}
|
|
17716
|
+
break;
|
|
17717
|
+
case 226 /* BinaryExpression */:
|
|
17718
|
+
const left = evaluate(expr.left, location);
|
|
17719
|
+
const right = evaluate(expr.right, location);
|
|
17720
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
17721
|
+
switch (expr.operatorToken.kind) {
|
|
17722
|
+
case 52 /* BarToken */:
|
|
17723
|
+
return left | right;
|
|
17724
|
+
case 51 /* AmpersandToken */:
|
|
17725
|
+
return left & right;
|
|
17726
|
+
case 49 /* GreaterThanGreaterThanToken */:
|
|
17727
|
+
return left >> right;
|
|
17728
|
+
case 50 /* GreaterThanGreaterThanGreaterThanToken */:
|
|
17729
|
+
return left >>> right;
|
|
17730
|
+
case 48 /* LessThanLessThanToken */:
|
|
17731
|
+
return left << right;
|
|
17732
|
+
case 53 /* CaretToken */:
|
|
17733
|
+
return left ^ right;
|
|
17734
|
+
case 42 /* AsteriskToken */:
|
|
17735
|
+
return left * right;
|
|
17736
|
+
case 44 /* SlashToken */:
|
|
17737
|
+
return left / right;
|
|
17738
|
+
case 40 /* PlusToken */:
|
|
17739
|
+
return left + right;
|
|
17740
|
+
case 41 /* MinusToken */:
|
|
17741
|
+
return left - right;
|
|
17742
|
+
case 45 /* PercentToken */:
|
|
17743
|
+
return left % right;
|
|
17744
|
+
case 43 /* AsteriskAsteriskToken */:
|
|
17745
|
+
return left ** right;
|
|
17746
|
+
}
|
|
17747
|
+
} else if ((typeof left === "string" || typeof left === "number") && (typeof right === "string" || typeof right === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
|
|
17748
|
+
return "" + left + right;
|
|
17749
|
+
}
|
|
17750
|
+
break;
|
|
17751
|
+
case 11 /* StringLiteral */:
|
|
17752
|
+
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
17753
|
+
return expr.text;
|
|
17754
|
+
case 228 /* TemplateExpression */:
|
|
17755
|
+
return evaluateTemplateExpression(expr, location);
|
|
17756
|
+
case 9 /* NumericLiteral */:
|
|
17757
|
+
return +expr.text;
|
|
17758
|
+
case 217 /* ParenthesizedExpression */:
|
|
17759
|
+
return evaluate(expr.expression, location);
|
|
17760
|
+
case 80 /* Identifier */:
|
|
17761
|
+
return evaluateEntityNameExpression(expr, location);
|
|
17762
|
+
case 211 /* PropertyAccessExpression */:
|
|
17763
|
+
if (isEntityNameExpression(expr)) {
|
|
17764
|
+
return evaluateEntityNameExpression(expr, location);
|
|
17765
|
+
}
|
|
17766
|
+
break;
|
|
17767
|
+
case 212 /* ElementAccessExpression */:
|
|
17768
|
+
return evaluateElementAccessExpression(expr, location);
|
|
17769
|
+
}
|
|
17770
|
+
return void 0;
|
|
17771
|
+
}
|
|
17772
|
+
function evaluateTemplateExpression(expr, location) {
|
|
17773
|
+
let result = expr.head.text;
|
|
17774
|
+
for (const span of expr.templateSpans) {
|
|
17775
|
+
const value = evaluate(span.expression, location);
|
|
17776
|
+
if (value === void 0) {
|
|
17777
|
+
return void 0;
|
|
17778
|
+
}
|
|
17779
|
+
result += value;
|
|
17780
|
+
result += span.literal.text;
|
|
17781
|
+
}
|
|
17782
|
+
return result;
|
|
17783
|
+
}
|
|
17784
|
+
return evaluate;
|
|
17785
|
+
}
|
|
17700
17786
|
|
|
17701
17787
|
// src/compiler/factory/baseNodeFactory.ts
|
|
17702
17788
|
function createBaseNodeFactory() {
|
|
@@ -43370,6 +43456,10 @@ function createTypeChecker(host) {
|
|
|
43370
43456
|
var checkBinaryExpression = createCheckBinaryExpression();
|
|
43371
43457
|
var emitResolver = createResolver();
|
|
43372
43458
|
var nodeBuilder = createNodeBuilder();
|
|
43459
|
+
var evaluate = createEvaluator({
|
|
43460
|
+
evaluateElementAccessExpression,
|
|
43461
|
+
evaluateEntityNameExpression
|
|
43462
|
+
});
|
|
43373
43463
|
var globals = createSymbolTable();
|
|
43374
43464
|
var undefinedSymbol = createSymbol(4 /* Property */, "undefined");
|
|
43375
43465
|
undefinedSymbol.declarations = [];
|
|
@@ -48540,7 +48630,7 @@ function createTypeChecker(host) {
|
|
|
48540
48630
|
}
|
|
48541
48631
|
const abstractSignatures = filter(resolved.constructSignatures, (signature) => !!(signature.flags & 4 /* Abstract */));
|
|
48542
48632
|
if (some(abstractSignatures)) {
|
|
48543
|
-
const types = map(abstractSignatures, getOrCreateTypeFromSignature);
|
|
48633
|
+
const types = map(abstractSignatures, (s) => getOrCreateTypeFromSignature(s));
|
|
48544
48634
|
const typeElementCount = resolved.callSignatures.length + (resolved.constructSignatures.length - abstractSignatures.length) + resolved.indexInfos.length + // exclude `prototype` when writing a class expression as a type literal, as per
|
|
48545
48635
|
// the logic in `createTypeNodesFromResolvedType`.
|
|
48546
48636
|
(context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? countWhere(resolved.properties, (p) => !(p.flags & 4194304 /* Prototype */)) : length(resolved.properties));
|
|
@@ -49855,7 +49945,7 @@ function createTypeChecker(host) {
|
|
|
49855
49945
|
const type = getDeclaredTypeOfSymbol(sym);
|
|
49856
49946
|
const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node);
|
|
49857
49947
|
name.symbol = sym;
|
|
49858
|
-
return { introducesError, node: setEmitFlags(setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
|
|
49948
|
+
return { introducesError, node: setTextRange(setEmitFlags(setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */), node) };
|
|
49859
49949
|
}
|
|
49860
49950
|
}
|
|
49861
49951
|
return { introducesError, node };
|
|
@@ -49865,7 +49955,6 @@ function createTypeChecker(host) {
|
|
|
49865
49955
|
cancellationToken.throwIfCancellationRequested();
|
|
49866
49956
|
}
|
|
49867
49957
|
let hadError = false;
|
|
49868
|
-
const file = getSourceFileOfNode(existing);
|
|
49869
49958
|
const transformed = visitNode(existing, visitExistingNodeTreeSymbols, isTypeNode);
|
|
49870
49959
|
if (hadError) {
|
|
49871
49960
|
return void 0;
|
|
@@ -50016,8 +50105,17 @@ function createTypeChecker(host) {
|
|
|
50016
50105
|
return result;
|
|
50017
50106
|
}
|
|
50018
50107
|
}
|
|
50019
|
-
if (
|
|
50020
|
-
|
|
50108
|
+
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
|
|
50109
|
+
const visited = visitEachChild(
|
|
50110
|
+
node,
|
|
50111
|
+
visitExistingNodeTreeSymbols,
|
|
50112
|
+
/*context*/
|
|
50113
|
+
void 0
|
|
50114
|
+
);
|
|
50115
|
+
const clone = setTextRange(visited === node ? factory.cloneNode(node) : visited, node);
|
|
50116
|
+
const flags = getEmitFlags(clone);
|
|
50117
|
+
setEmitFlags(clone, flags | (context.flags & 1024 /* MultilineObjectLiterals */ && isTypeLiteralNode(node) ? 0 : 1 /* SingleLine */));
|
|
50118
|
+
return clone;
|
|
50021
50119
|
}
|
|
50022
50120
|
return visitEachChild(
|
|
50023
50121
|
node,
|
|
@@ -54697,11 +54795,15 @@ function createTypeChecker(host) {
|
|
|
54697
54795
|
const modifiers = getMappedTypeModifiers(type);
|
|
54698
54796
|
return modifiers & 8 /* ExcludeOptional */ ? -1 : modifiers & 4 /* IncludeOptional */ ? 1 : 0;
|
|
54699
54797
|
}
|
|
54700
|
-
function getModifiersTypeOptionality(type) {
|
|
54701
|
-
return type.flags & 2097152 /* Intersection */ ? Math.max(...map(type.types, getModifiersTypeOptionality)) : getObjectFlags(type) & 32 /* Mapped */ ? getCombinedMappedTypeOptionality(type) : 0;
|
|
54702
|
-
}
|
|
54703
54798
|
function getCombinedMappedTypeOptionality(type) {
|
|
54704
|
-
|
|
54799
|
+
if (getObjectFlags(type) & 32 /* Mapped */) {
|
|
54800
|
+
return getMappedTypeOptionality(type) || getCombinedMappedTypeOptionality(getModifiersTypeFromMappedType(type));
|
|
54801
|
+
}
|
|
54802
|
+
if (type.flags & 2097152 /* Intersection */) {
|
|
54803
|
+
const optionality = getCombinedMappedTypeOptionality(type.types[0]);
|
|
54804
|
+
return every(type.types, (t, i) => i === 0 || getCombinedMappedTypeOptionality(t) === optionality) ? optionality : 0;
|
|
54805
|
+
}
|
|
54806
|
+
return 0;
|
|
54705
54807
|
}
|
|
54706
54808
|
function isPartialMappedType(type) {
|
|
54707
54809
|
return !!(getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */);
|
|
@@ -55978,6 +56080,12 @@ function createTypeChecker(host) {
|
|
|
55978
56080
|
isInJSFile(signature.declaration)
|
|
55979
56081
|
);
|
|
55980
56082
|
}
|
|
56083
|
+
function getImplementationSignature(signature) {
|
|
56084
|
+
return signature.typeParameters ? signature.implementationSignatureCache || (signature.implementationSignatureCache = createImplementationSignature(signature)) : signature;
|
|
56085
|
+
}
|
|
56086
|
+
function createImplementationSignature(signature) {
|
|
56087
|
+
return signature.typeParameters ? instantiateSignature(signature, createTypeMapper([], [])) : signature;
|
|
56088
|
+
}
|
|
55981
56089
|
function getBaseSignature(signature) {
|
|
55982
56090
|
const typeParameters = signature.typeParameters;
|
|
55983
56091
|
if (typeParameters) {
|
|
@@ -56000,12 +56108,22 @@ function createTypeChecker(host) {
|
|
|
56000
56108
|
}
|
|
56001
56109
|
return signature;
|
|
56002
56110
|
}
|
|
56003
|
-
function getOrCreateTypeFromSignature(signature) {
|
|
56111
|
+
function getOrCreateTypeFromSignature(signature, outerTypeParameters) {
|
|
56004
56112
|
var _a;
|
|
56005
56113
|
if (!signature.isolatedSignatureType) {
|
|
56006
56114
|
const kind = (_a = signature.declaration) == null ? void 0 : _a.kind;
|
|
56007
56115
|
const isConstructor = kind === void 0 || kind === 176 /* Constructor */ || kind === 180 /* ConstructSignature */ || kind === 185 /* ConstructorType */;
|
|
56008
|
-
const type = createObjectType(16 /* Anonymous */);
|
|
56116
|
+
const type = createObjectType(16 /* Anonymous */ | 134217728 /* SingleSignatureType */, createSymbol(16 /* Function */, "__function" /* Function */));
|
|
56117
|
+
if (signature.declaration && !nodeIsSynthesized(signature.declaration)) {
|
|
56118
|
+
type.symbol.declarations = [signature.declaration];
|
|
56119
|
+
type.symbol.valueDeclaration = signature.declaration;
|
|
56120
|
+
}
|
|
56121
|
+
outerTypeParameters || (outerTypeParameters = signature.declaration && getOuterTypeParameters(
|
|
56122
|
+
signature.declaration,
|
|
56123
|
+
/*includeThisTypes*/
|
|
56124
|
+
true
|
|
56125
|
+
));
|
|
56126
|
+
type.outerTypeParameters = outerTypeParameters;
|
|
56009
56127
|
type.members = emptySymbols;
|
|
56010
56128
|
type.properties = emptyArray;
|
|
56011
56129
|
type.callSignatures = !isConstructor ? [signature] : emptyArray;
|
|
@@ -58494,13 +58612,18 @@ function createTypeChecker(host) {
|
|
|
58494
58612
|
const mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]);
|
|
58495
58613
|
const templateMapper = combineTypeMappers(objectType.mapper, mapper);
|
|
58496
58614
|
const instantiatedTemplateType = instantiateType(getTemplateTypeFromMappedType(objectType.target || objectType), templateMapper);
|
|
58615
|
+
const isOptional = getMappedTypeOptionality(objectType) > 0 || (isGenericType(objectType) ? getCombinedMappedTypeOptionality(getModifiersTypeFromMappedType(objectType)) > 0 : couldAccessOptionalProperty(objectType, index));
|
|
58497
58616
|
return addOptionality(
|
|
58498
58617
|
instantiatedTemplateType,
|
|
58499
58618
|
/*isProperty*/
|
|
58500
58619
|
true,
|
|
58501
|
-
|
|
58620
|
+
isOptional
|
|
58502
58621
|
);
|
|
58503
58622
|
}
|
|
58623
|
+
function couldAccessOptionalProperty(objectType, indexType) {
|
|
58624
|
+
const indexConstraint = getBaseConstraintOfType(indexType);
|
|
58625
|
+
return !!indexConstraint && some(getPropertiesOfType(objectType), (p) => !!(p.flags & 16777216 /* Optional */) && isTypeAssignableTo(getLiteralTypeFromProperty(p, 8576 /* StringOrNumberLiteralOrUnique */), indexConstraint));
|
|
58626
|
+
}
|
|
58504
58627
|
function getIndexedAccessType(objectType, indexType, accessFlags = 0 /* None */, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
58505
58628
|
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
|
|
58506
58629
|
}
|
|
@@ -59411,7 +59534,7 @@ function createTypeChecker(host) {
|
|
|
59411
59534
|
const declaration = type.objectFlags & 4 /* Reference */ ? type.node : type.objectFlags & 8388608 /* InstantiationExpressionType */ ? type.node : type.symbol.declarations[0];
|
|
59412
59535
|
const links = getNodeLinks(declaration);
|
|
59413
59536
|
const target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : type.objectFlags & 64 /* Instantiated */ ? type.target : type;
|
|
59414
|
-
let typeParameters = links.outerTypeParameters;
|
|
59537
|
+
let typeParameters = type.objectFlags & 134217728 /* SingleSignatureType */ ? type.outerTypeParameters : links.outerTypeParameters;
|
|
59415
59538
|
if (!typeParameters) {
|
|
59416
59539
|
let outerTypeParameters = getOuterTypeParameters(
|
|
59417
59540
|
declaration,
|
|
@@ -59591,6 +59714,9 @@ function createTypeChecker(host) {
|
|
|
59591
59714
|
if (type.objectFlags & 8388608 /* InstantiationExpressionType */) {
|
|
59592
59715
|
result.node = type.node;
|
|
59593
59716
|
}
|
|
59717
|
+
if (type.objectFlags & 134217728 /* SingleSignatureType */) {
|
|
59718
|
+
result.outerTypeParameters = type.outerTypeParameters;
|
|
59719
|
+
}
|
|
59594
59720
|
result.target = type;
|
|
59595
59721
|
result.mapper = mapper;
|
|
59596
59722
|
result.aliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
@@ -64222,7 +64348,7 @@ function createTypeChecker(host) {
|
|
|
64222
64348
|
if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
|
|
64223
64349
|
return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
|
|
64224
64350
|
}
|
|
64225
|
-
const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
|
|
64351
|
+
const result = !!(type.flags & 465829888 /* Instantiable */ || type.flags & 524288 /* Object */ && !isNonGenericTopLevelType(type) && (objectFlags & 4 /* Reference */ && (type.node || some(getTypeArguments(type), couldContainTypeVariables)) || objectFlags & 134217728 /* SingleSignatureType */ && !!length(type.outerTypeParameters) || objectFlags & 16 /* Anonymous */ && type.symbol && type.symbol.flags & (16 /* Function */ | 8192 /* Method */ | 32 /* Class */ | 2048 /* TypeLiteral */ | 4096 /* ObjectLiteral */) && type.symbol.declarations || objectFlags & (32 /* Mapped */ | 1024 /* ReverseMapped */ | 4194304 /* ObjectRestType */ | 8388608 /* InstantiationExpressionType */)) || type.flags & 3145728 /* UnionOrIntersection */ && !(type.flags & 1024 /* EnumLiteral */) && !isNonGenericTopLevelType(type) && some(type.types, couldContainTypeVariables));
|
|
64226
64352
|
if (type.flags & 3899393 /* ObjectFlagsType */) {
|
|
64227
64353
|
type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
64228
64354
|
}
|
|
@@ -64506,6 +64632,9 @@ function createTypeChecker(host) {
|
|
|
64506
64632
|
pos = p;
|
|
64507
64633
|
}
|
|
64508
64634
|
}
|
|
64635
|
+
function isTupleOfSelf(typeParameter, type) {
|
|
64636
|
+
return isTupleType(type) && getTupleElementType(type, 0) === getIndexedAccessType(typeParameter, getNumberLiteralType(0)) && !getTypeOfPropertyOfType(type, "1");
|
|
64637
|
+
}
|
|
64509
64638
|
function inferTypes(inferences, originalSource, originalTarget, priority = 0 /* None */, contravariant = false) {
|
|
64510
64639
|
let bivariant = false;
|
|
64511
64640
|
let propagationType;
|
|
@@ -64591,6 +64720,9 @@ function createTypeChecker(host) {
|
|
|
64591
64720
|
inference.priority = priority;
|
|
64592
64721
|
}
|
|
64593
64722
|
if (priority === inference.priority) {
|
|
64723
|
+
if (isTupleOfSelf(inference.typeParameter, candidate)) {
|
|
64724
|
+
return;
|
|
64725
|
+
}
|
|
64594
64726
|
if (contravariant && !bivariant) {
|
|
64595
64727
|
if (!contains(inference.contraCandidates, candidate)) {
|
|
64596
64728
|
inference.contraCandidates = append(inference.contraCandidates, candidate);
|
|
@@ -71529,7 +71661,7 @@ function createTypeChecker(host) {
|
|
|
71529
71661
|
argument = skipParentheses(argument);
|
|
71530
71662
|
return isSatisfiesExpression(argument) ? skipParentheses(argument.expression) : argument;
|
|
71531
71663
|
}
|
|
71532
|
-
function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors2, containingMessageChain) {
|
|
71664
|
+
function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors2, containingMessageChain, inferenceContext) {
|
|
71533
71665
|
const errorOutputContainer = { errors: void 0, skipLogging: true };
|
|
71534
71666
|
if (isJsxOpeningLikeElement(node)) {
|
|
71535
71667
|
if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors2, containingMessageChain, errorOutputContainer)) {
|
|
@@ -71563,7 +71695,8 @@ function createTypeChecker(host) {
|
|
|
71563
71695
|
void 0,
|
|
71564
71696
|
checkMode
|
|
71565
71697
|
);
|
|
71566
|
-
const
|
|
71698
|
+
const regularArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType;
|
|
71699
|
+
const checkArgType = inferenceContext ? instantiateType(regularArgType, inferenceContext.nonFixingMapper) : regularArgType;
|
|
71567
71700
|
const effectiveCheckArgumentNode = getEffectiveCheckNode(arg);
|
|
71568
71701
|
if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors2 ? effectiveCheckArgumentNode : void 0, effectiveCheckArgumentNode, headMessage, containingMessageChain, errorOutputContainer)) {
|
|
71569
71702
|
Debug.assert(!reportErrors2 || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
|
|
@@ -71975,7 +72108,9 @@ function createTypeChecker(host) {
|
|
|
71975
72108
|
0 /* Normal */,
|
|
71976
72109
|
/*reportErrors*/
|
|
71977
72110
|
true,
|
|
71978
|
-
() => chain
|
|
72111
|
+
() => chain,
|
|
72112
|
+
/*inferenceContext*/
|
|
72113
|
+
void 0
|
|
71979
72114
|
);
|
|
71980
72115
|
if (diags) {
|
|
71981
72116
|
for (const d of diags) {
|
|
@@ -72011,7 +72146,9 @@ function createTypeChecker(host) {
|
|
|
72011
72146
|
0 /* Normal */,
|
|
72012
72147
|
/*reportErrors*/
|
|
72013
72148
|
true,
|
|
72014
|
-
chain2
|
|
72149
|
+
chain2,
|
|
72150
|
+
/*inferenceContext*/
|
|
72151
|
+
void 0
|
|
72015
72152
|
);
|
|
72016
72153
|
if (diags2) {
|
|
72017
72154
|
if (diags2.length <= min2) {
|
|
@@ -72102,6 +72239,8 @@ function createTypeChecker(host) {
|
|
|
72102
72239
|
/*reportErrors*/
|
|
72103
72240
|
false,
|
|
72104
72241
|
/*containingMessageChain*/
|
|
72242
|
+
void 0,
|
|
72243
|
+
/*inferenceContext*/
|
|
72105
72244
|
void 0
|
|
72106
72245
|
)) {
|
|
72107
72246
|
candidatesForArgumentError = [candidate];
|
|
@@ -72110,13 +72249,16 @@ function createTypeChecker(host) {
|
|
|
72110
72249
|
return candidate;
|
|
72111
72250
|
}
|
|
72112
72251
|
for (let candidateIndex = 0; candidateIndex < candidates2.length; candidateIndex++) {
|
|
72113
|
-
|
|
72252
|
+
let candidate = candidates2[candidateIndex];
|
|
72114
72253
|
if (!hasCorrectTypeArgumentArity(candidate, typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma2)) {
|
|
72115
72254
|
continue;
|
|
72116
72255
|
}
|
|
72117
72256
|
let checkCandidate;
|
|
72118
72257
|
let inferenceContext;
|
|
72119
72258
|
if (candidate.typeParameters) {
|
|
72259
|
+
if (candidate.declaration && findAncestor(node, (a) => a === candidate.declaration)) {
|
|
72260
|
+
candidate = getImplementationSignature(candidate);
|
|
72261
|
+
}
|
|
72120
72262
|
let typeArgumentTypes;
|
|
72121
72263
|
if (some(typeArguments)) {
|
|
72122
72264
|
typeArgumentTypes = checkTypeArguments(
|
|
@@ -72136,7 +72278,7 @@ function createTypeChecker(host) {
|
|
|
72136
72278
|
/*flags*/
|
|
72137
72279
|
isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */
|
|
72138
72280
|
);
|
|
72139
|
-
typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
72281
|
+
typeArgumentTypes = instantiateTypes(inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext), inferenceContext.nonFixingMapper);
|
|
72140
72282
|
argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */;
|
|
72141
72283
|
}
|
|
72142
72284
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
|
|
@@ -72156,7 +72298,8 @@ function createTypeChecker(host) {
|
|
|
72156
72298
|
/*reportErrors*/
|
|
72157
72299
|
false,
|
|
72158
72300
|
/*containingMessageChain*/
|
|
72159
|
-
void 0
|
|
72301
|
+
void 0,
|
|
72302
|
+
inferenceContext
|
|
72160
72303
|
)) {
|
|
72161
72304
|
(candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
|
|
72162
72305
|
continue;
|
|
@@ -72164,7 +72307,7 @@ function createTypeChecker(host) {
|
|
|
72164
72307
|
if (argCheckMode) {
|
|
72165
72308
|
argCheckMode = 0 /* Normal */;
|
|
72166
72309
|
if (inferenceContext) {
|
|
72167
|
-
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
72310
|
+
const typeArgumentTypes = instantiateTypes(inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext), inferenceContext.mapper);
|
|
72168
72311
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
72169
72312
|
if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma2)) {
|
|
72170
72313
|
candidateForArgumentArityError = checkCandidate;
|
|
@@ -72180,7 +72323,8 @@ function createTypeChecker(host) {
|
|
|
72180
72323
|
/*reportErrors*/
|
|
72181
72324
|
false,
|
|
72182
72325
|
/*containingMessageChain*/
|
|
72183
|
-
void 0
|
|
72326
|
+
void 0,
|
|
72327
|
+
inferenceContext
|
|
72184
72328
|
)) {
|
|
72185
72329
|
(candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
|
|
72186
72330
|
continue;
|
|
@@ -75720,7 +75864,7 @@ function createTypeChecker(host) {
|
|
|
75720
75864
|
) || unknownType, isTemplateLiteralContextualType)) {
|
|
75721
75865
|
return getTemplateLiteralType(texts, types);
|
|
75722
75866
|
}
|
|
75723
|
-
const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ &&
|
|
75867
|
+
const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node);
|
|
75724
75868
|
return evaluated ? getFreshTypeOfLiteralType(getStringLiteralType(evaluated)) : stringType;
|
|
75725
75869
|
}
|
|
75726
75870
|
function isTemplateLiteralContextualType(type) {
|
|
@@ -75934,7 +76078,7 @@ function createTypeChecker(host) {
|
|
|
75934
76078
|
}
|
|
75935
76079
|
}
|
|
75936
76080
|
}
|
|
75937
|
-
return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context));
|
|
76081
|
+
return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context), flatMap(inferenceContexts, (c) => c && map(c.inferences, (i) => i.typeParameter)).slice());
|
|
75938
76082
|
}
|
|
75939
76083
|
}
|
|
75940
76084
|
}
|
|
@@ -76109,7 +76253,8 @@ function createTypeChecker(host) {
|
|
|
76109
76253
|
if (getIsolatedModules(compilerOptions)) {
|
|
76110
76254
|
Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
|
|
76111
76255
|
const constEnumDeclaration = type.symbol.valueDeclaration;
|
|
76112
|
-
|
|
76256
|
+
const redirect = host.getRedirectReferenceForResolutionFromSourceOfProject(getSourceFileOfNode(constEnumDeclaration).resolvedPath);
|
|
76257
|
+
if (constEnumDeclaration.flags & 33554432 /* Ambient */ && !isValidTypeOnlyAliasUseSite(node) && (!redirect || !shouldPreserveConstEnums(redirect.commandLine.options))) {
|
|
76113
76258
|
error(node, Diagnostics.Cannot_access_ambient_const_enums_when_0_is_enabled, isolatedModulesLikeFlagName);
|
|
76114
76259
|
}
|
|
76115
76260
|
}
|
|
@@ -80696,122 +80841,53 @@ function createTypeChecker(host) {
|
|
|
80696
80841
|
}
|
|
80697
80842
|
return false;
|
|
80698
80843
|
}
|
|
80699
|
-
function
|
|
80700
|
-
|
|
80701
|
-
|
|
80702
|
-
|
|
80703
|
-
|
|
80704
|
-
|
|
80705
|
-
|
|
80706
|
-
|
|
80707
|
-
|
|
80708
|
-
|
|
80709
|
-
|
|
80710
|
-
|
|
80711
|
-
|
|
80712
|
-
|
|
80713
|
-
|
|
80714
|
-
|
|
80715
|
-
|
|
80716
|
-
|
|
80717
|
-
if (typeof left === "number" && typeof right === "number") {
|
|
80718
|
-
switch (expr.operatorToken.kind) {
|
|
80719
|
-
case 52 /* BarToken */:
|
|
80720
|
-
return left | right;
|
|
80721
|
-
case 51 /* AmpersandToken */:
|
|
80722
|
-
return left & right;
|
|
80723
|
-
case 49 /* GreaterThanGreaterThanToken */:
|
|
80724
|
-
return left >> right;
|
|
80725
|
-
case 50 /* GreaterThanGreaterThanGreaterThanToken */:
|
|
80726
|
-
return left >>> right;
|
|
80727
|
-
case 48 /* LessThanLessThanToken */:
|
|
80728
|
-
return left << right;
|
|
80729
|
-
case 53 /* CaretToken */:
|
|
80730
|
-
return left ^ right;
|
|
80731
|
-
case 42 /* AsteriskToken */:
|
|
80732
|
-
return left * right;
|
|
80733
|
-
case 44 /* SlashToken */:
|
|
80734
|
-
return left / right;
|
|
80735
|
-
case 40 /* PlusToken */:
|
|
80736
|
-
return left + right;
|
|
80737
|
-
case 41 /* MinusToken */:
|
|
80738
|
-
return left - right;
|
|
80739
|
-
case 45 /* PercentToken */:
|
|
80740
|
-
return left % right;
|
|
80741
|
-
case 43 /* AsteriskAsteriskToken */:
|
|
80742
|
-
return left ** right;
|
|
80743
|
-
}
|
|
80744
|
-
} else if ((typeof left === "string" || typeof left === "number") && (typeof right === "string" || typeof right === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
|
|
80745
|
-
return "" + left + right;
|
|
80746
|
-
}
|
|
80747
|
-
break;
|
|
80748
|
-
case 11 /* StringLiteral */:
|
|
80749
|
-
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
80750
|
-
return expr.text;
|
|
80751
|
-
case 228 /* TemplateExpression */:
|
|
80752
|
-
return evaluateTemplateExpression(expr, location);
|
|
80753
|
-
case 9 /* NumericLiteral */:
|
|
80754
|
-
checkGrammarNumericLiteral(expr);
|
|
80755
|
-
return +expr.text;
|
|
80756
|
-
case 217 /* ParenthesizedExpression */:
|
|
80757
|
-
return evaluate(expr.expression, location);
|
|
80758
|
-
case 80 /* Identifier */: {
|
|
80759
|
-
const identifier = expr;
|
|
80760
|
-
if (isInfinityOrNaNString(identifier.escapedText) && resolveEntityName(
|
|
80761
|
-
identifier,
|
|
80762
|
-
111551 /* Value */,
|
|
80763
|
-
/*ignoreErrors*/
|
|
80764
|
-
true
|
|
80765
|
-
) === getGlobalSymbol(
|
|
80766
|
-
identifier.escapedText,
|
|
80767
|
-
111551 /* Value */,
|
|
80768
|
-
/*diagnostic*/
|
|
80769
|
-
void 0
|
|
80770
|
-
)) {
|
|
80771
|
-
return +identifier.escapedText;
|
|
80772
|
-
}
|
|
80844
|
+
function evaluateEntityNameExpression(expr, location) {
|
|
80845
|
+
const symbol = resolveEntityName(
|
|
80846
|
+
expr,
|
|
80847
|
+
111551 /* Value */,
|
|
80848
|
+
/*ignoreErrors*/
|
|
80849
|
+
true
|
|
80850
|
+
);
|
|
80851
|
+
if (!symbol)
|
|
80852
|
+
return void 0;
|
|
80853
|
+
if (expr.kind === 80 /* Identifier */) {
|
|
80854
|
+
const identifier = expr;
|
|
80855
|
+
if (isInfinityOrNaNString(identifier.escapedText) && symbol === getGlobalSymbol(
|
|
80856
|
+
identifier.escapedText,
|
|
80857
|
+
111551 /* Value */,
|
|
80858
|
+
/*diagnostic*/
|
|
80859
|
+
void 0
|
|
80860
|
+
)) {
|
|
80861
|
+
return +identifier.escapedText;
|
|
80773
80862
|
}
|
|
80774
|
-
|
|
80775
|
-
|
|
80776
|
-
|
|
80777
|
-
|
|
80778
|
-
|
|
80779
|
-
|
|
80780
|
-
|
|
80781
|
-
|
|
80782
|
-
|
|
80783
|
-
|
|
80784
|
-
|
|
80785
|
-
|
|
80786
|
-
|
|
80787
|
-
|
|
80788
|
-
|
|
80789
|
-
|
|
80790
|
-
|
|
80791
|
-
|
|
80792
|
-
|
|
80793
|
-
|
|
80794
|
-
|
|
80795
|
-
|
|
80796
|
-
const
|
|
80797
|
-
if (
|
|
80798
|
-
|
|
80799
|
-
root,
|
|
80800
|
-
111551 /* Value */,
|
|
80801
|
-
/*ignoreErrors*/
|
|
80802
|
-
true
|
|
80803
|
-
);
|
|
80804
|
-
if (rootSymbol && rootSymbol.flags & 384 /* Enum */) {
|
|
80805
|
-
const name = escapeLeadingUnderscores(expr.argumentExpression.text);
|
|
80806
|
-
const member = rootSymbol.exports.get(name);
|
|
80807
|
-
if (member) {
|
|
80808
|
-
return location ? evaluateEnumMember(expr, member, location) : getEnumMemberValue(member.valueDeclaration);
|
|
80809
|
-
}
|
|
80810
|
-
}
|
|
80863
|
+
}
|
|
80864
|
+
if (symbol.flags & 8 /* EnumMember */) {
|
|
80865
|
+
return location ? evaluateEnumMember(expr, symbol, location) : getEnumMemberValue(symbol.valueDeclaration);
|
|
80866
|
+
}
|
|
80867
|
+
if (isConstantVariable(symbol)) {
|
|
80868
|
+
const declaration = symbol.valueDeclaration;
|
|
80869
|
+
if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
|
|
80870
|
+
return evaluate(declaration.initializer, declaration);
|
|
80871
|
+
}
|
|
80872
|
+
}
|
|
80873
|
+
}
|
|
80874
|
+
function evaluateElementAccessExpression(expr, location) {
|
|
80875
|
+
const root = expr.expression;
|
|
80876
|
+
if (isEntityNameExpression(root) && isStringLiteralLike(expr.argumentExpression)) {
|
|
80877
|
+
const rootSymbol = resolveEntityName(
|
|
80878
|
+
root,
|
|
80879
|
+
111551 /* Value */,
|
|
80880
|
+
/*ignoreErrors*/
|
|
80881
|
+
true
|
|
80882
|
+
);
|
|
80883
|
+
if (rootSymbol && rootSymbol.flags & 384 /* Enum */) {
|
|
80884
|
+
const name = escapeLeadingUnderscores(expr.argumentExpression.text);
|
|
80885
|
+
const member = rootSymbol.exports.get(name);
|
|
80886
|
+
if (member) {
|
|
80887
|
+
return location ? evaluateEnumMember(expr, member, location) : getEnumMemberValue(member.valueDeclaration);
|
|
80811
80888
|
}
|
|
80812
|
-
|
|
80889
|
+
}
|
|
80813
80890
|
}
|
|
80814
|
-
return void 0;
|
|
80815
80891
|
}
|
|
80816
80892
|
function evaluateEnumMember(expr, symbol, location) {
|
|
80817
80893
|
const declaration = symbol.valueDeclaration;
|
|
@@ -80825,18 +80901,6 @@ function createTypeChecker(host) {
|
|
|
80825
80901
|
}
|
|
80826
80902
|
return getEnumMemberValue(declaration);
|
|
80827
80903
|
}
|
|
80828
|
-
function evaluateTemplateExpression(expr, location) {
|
|
80829
|
-
let result = expr.head.text;
|
|
80830
|
-
for (const span of expr.templateSpans) {
|
|
80831
|
-
const value = evaluate(span.expression, location);
|
|
80832
|
-
if (value === void 0) {
|
|
80833
|
-
return void 0;
|
|
80834
|
-
}
|
|
80835
|
-
result += value;
|
|
80836
|
-
result += span.literal.text;
|
|
80837
|
-
}
|
|
80838
|
-
return result;
|
|
80839
|
-
}
|
|
80840
80904
|
function checkEnumDeclaration(node) {
|
|
80841
80905
|
addLazyDiagnostic(() => checkEnumDeclarationWorker(node));
|
|
80842
80906
|
}
|
|
@@ -117018,6 +117082,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
117018
117082
|
getResolvedProjectReferenceByPath,
|
|
117019
117083
|
forEachResolvedProjectReference: forEachResolvedProjectReference2,
|
|
117020
117084
|
isSourceOfProjectReferenceRedirect,
|
|
117085
|
+
getRedirectReferenceForResolutionFromSourceOfProject,
|
|
117021
117086
|
emitBuildInfo,
|
|
117022
117087
|
fileExists,
|
|
117023
117088
|
readFile,
|
package/lib/typescript.d.ts
CHANGED
|
@@ -1342,12 +1342,13 @@ declare namespace ts {
|
|
|
1342
1342
|
}
|
|
1343
1343
|
export interface WatchChangeRequest extends Request {
|
|
1344
1344
|
command: CommandTypes.WatchChange;
|
|
1345
|
-
arguments: WatchChangeRequestArgs;
|
|
1345
|
+
arguments: WatchChangeRequestArgs | readonly WatchChangeRequestArgs[];
|
|
1346
1346
|
}
|
|
1347
1347
|
export interface WatchChangeRequestArgs {
|
|
1348
1348
|
id: number;
|
|
1349
|
-
|
|
1350
|
-
|
|
1349
|
+
created?: string[];
|
|
1350
|
+
deleted?: string[];
|
|
1351
|
+
updated?: string[];
|
|
1351
1352
|
}
|
|
1352
1353
|
/**
|
|
1353
1354
|
* Request to obtain the list of files that should be regenerated if target file is recompiled.
|
|
@@ -2032,6 +2033,7 @@ declare namespace ts {
|
|
|
2032
2033
|
readonly id: number;
|
|
2033
2034
|
readonly path: string;
|
|
2034
2035
|
readonly recursive: boolean;
|
|
2036
|
+
readonly ignoreUpdate?: boolean;
|
|
2035
2037
|
}
|
|
2036
2038
|
export type CloseFileWatcherEventName = "closeFileWatcher";
|
|
2037
2039
|
export interface CloseFileWatcherEvent extends Event {
|
|
@@ -6598,6 +6600,7 @@ declare namespace ts {
|
|
|
6598
6600
|
ContainsSpread = 2097152,
|
|
6599
6601
|
ObjectRestType = 4194304,
|
|
6600
6602
|
InstantiationExpressionType = 8388608,
|
|
6603
|
+
SingleSignatureType = 134217728,
|
|
6601
6604
|
}
|
|
6602
6605
|
interface ObjectType extends Type {
|
|
6603
6606
|
objectFlags: ObjectFlags;
|