typescript 5.5.0-dev.20240327 → 5.5.0-dev.20240329
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 +373 -304
- package/lib/typescript.d.ts +6 -3
- package/lib/typescript.js +448 -360
- package/package.json +2 -2
package/lib/typescript.js
CHANGED
|
@@ -402,6 +402,7 @@ __export(typescript_exports, {
|
|
|
402
402
|
createEmitAndSemanticDiagnosticsBuilderProgram: () => createEmitAndSemanticDiagnosticsBuilderProgram,
|
|
403
403
|
createEmitHelperFactory: () => createEmitHelperFactory,
|
|
404
404
|
createEmptyExports: () => createEmptyExports,
|
|
405
|
+
createEvaluator: () => createEvaluator,
|
|
405
406
|
createExpressionForJsxElement: () => createExpressionForJsxElement,
|
|
406
407
|
createExpressionForJsxFragment: () => createExpressionForJsxFragment,
|
|
407
408
|
createExpressionForObjectLiteralElementLike: () => createExpressionForObjectLiteralElementLike,
|
|
@@ -2327,7 +2328,7 @@ module.exports = __toCommonJS(typescript_exports);
|
|
|
2327
2328
|
|
|
2328
2329
|
// src/compiler/corePublic.ts
|
|
2329
2330
|
var versionMajorMinor = "5.5";
|
|
2330
|
-
var version = `${versionMajorMinor}.0-dev.
|
|
2331
|
+
var version = `${versionMajorMinor}.0-dev.20240329`;
|
|
2331
2332
|
var Comparison = /* @__PURE__ */ ((Comparison3) => {
|
|
2332
2333
|
Comparison3[Comparison3["LessThan"] = -1] = "LessThan";
|
|
2333
2334
|
Comparison3[Comparison3["EqualTo"] = 0] = "EqualTo";
|
|
@@ -6695,6 +6696,7 @@ var ObjectFlags = /* @__PURE__ */ ((ObjectFlags3) => {
|
|
|
6695
6696
|
ObjectFlags3[ObjectFlags3["ContainsSpread"] = 2097152] = "ContainsSpread";
|
|
6696
6697
|
ObjectFlags3[ObjectFlags3["ObjectRestType"] = 4194304] = "ObjectRestType";
|
|
6697
6698
|
ObjectFlags3[ObjectFlags3["InstantiationExpressionType"] = 8388608] = "InstantiationExpressionType";
|
|
6699
|
+
ObjectFlags3[ObjectFlags3["SingleSignatureType"] = 134217728] = "SingleSignatureType";
|
|
6698
6700
|
ObjectFlags3[ObjectFlags3["IsClassInstanceClone"] = 16777216] = "IsClassInstanceClone";
|
|
6699
6701
|
ObjectFlags3[ObjectFlags3["IdenticalBaseTypeCalculated"] = 33554432] = "IdenticalBaseTypeCalculated";
|
|
6700
6702
|
ObjectFlags3[ObjectFlags3["IdenticalBaseTypeExists"] = 67108864] = "IdenticalBaseTypeExists";
|
|
@@ -21935,6 +21937,91 @@ function isSyntacticallyString(expr) {
|
|
|
21935
21937
|
}
|
|
21936
21938
|
return false;
|
|
21937
21939
|
}
|
|
21940
|
+
function createEvaluator({ evaluateElementAccessExpression, evaluateEntityNameExpression }) {
|
|
21941
|
+
function evaluate(expr, location) {
|
|
21942
|
+
switch (expr.kind) {
|
|
21943
|
+
case 224 /* PrefixUnaryExpression */:
|
|
21944
|
+
const value = evaluate(expr.operand, location);
|
|
21945
|
+
if (typeof value === "number") {
|
|
21946
|
+
switch (expr.operator) {
|
|
21947
|
+
case 40 /* PlusToken */:
|
|
21948
|
+
return value;
|
|
21949
|
+
case 41 /* MinusToken */:
|
|
21950
|
+
return -value;
|
|
21951
|
+
case 55 /* TildeToken */:
|
|
21952
|
+
return ~value;
|
|
21953
|
+
}
|
|
21954
|
+
}
|
|
21955
|
+
break;
|
|
21956
|
+
case 226 /* BinaryExpression */:
|
|
21957
|
+
const left = evaluate(expr.left, location);
|
|
21958
|
+
const right = evaluate(expr.right, location);
|
|
21959
|
+
if (typeof left === "number" && typeof right === "number") {
|
|
21960
|
+
switch (expr.operatorToken.kind) {
|
|
21961
|
+
case 52 /* BarToken */:
|
|
21962
|
+
return left | right;
|
|
21963
|
+
case 51 /* AmpersandToken */:
|
|
21964
|
+
return left & right;
|
|
21965
|
+
case 49 /* GreaterThanGreaterThanToken */:
|
|
21966
|
+
return left >> right;
|
|
21967
|
+
case 50 /* GreaterThanGreaterThanGreaterThanToken */:
|
|
21968
|
+
return left >>> right;
|
|
21969
|
+
case 48 /* LessThanLessThanToken */:
|
|
21970
|
+
return left << right;
|
|
21971
|
+
case 53 /* CaretToken */:
|
|
21972
|
+
return left ^ right;
|
|
21973
|
+
case 42 /* AsteriskToken */:
|
|
21974
|
+
return left * right;
|
|
21975
|
+
case 44 /* SlashToken */:
|
|
21976
|
+
return left / right;
|
|
21977
|
+
case 40 /* PlusToken */:
|
|
21978
|
+
return left + right;
|
|
21979
|
+
case 41 /* MinusToken */:
|
|
21980
|
+
return left - right;
|
|
21981
|
+
case 45 /* PercentToken */:
|
|
21982
|
+
return left % right;
|
|
21983
|
+
case 43 /* AsteriskAsteriskToken */:
|
|
21984
|
+
return left ** right;
|
|
21985
|
+
}
|
|
21986
|
+
} else if ((typeof left === "string" || typeof left === "number") && (typeof right === "string" || typeof right === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
|
|
21987
|
+
return "" + left + right;
|
|
21988
|
+
}
|
|
21989
|
+
break;
|
|
21990
|
+
case 11 /* StringLiteral */:
|
|
21991
|
+
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
21992
|
+
return expr.text;
|
|
21993
|
+
case 228 /* TemplateExpression */:
|
|
21994
|
+
return evaluateTemplateExpression(expr, location);
|
|
21995
|
+
case 9 /* NumericLiteral */:
|
|
21996
|
+
return +expr.text;
|
|
21997
|
+
case 217 /* ParenthesizedExpression */:
|
|
21998
|
+
return evaluate(expr.expression, location);
|
|
21999
|
+
case 80 /* Identifier */:
|
|
22000
|
+
return evaluateEntityNameExpression(expr, location);
|
|
22001
|
+
case 211 /* PropertyAccessExpression */:
|
|
22002
|
+
if (isEntityNameExpression(expr)) {
|
|
22003
|
+
return evaluateEntityNameExpression(expr, location);
|
|
22004
|
+
}
|
|
22005
|
+
break;
|
|
22006
|
+
case 212 /* ElementAccessExpression */:
|
|
22007
|
+
return evaluateElementAccessExpression(expr, location);
|
|
22008
|
+
}
|
|
22009
|
+
return void 0;
|
|
22010
|
+
}
|
|
22011
|
+
function evaluateTemplateExpression(expr, location) {
|
|
22012
|
+
let result = expr.head.text;
|
|
22013
|
+
for (const span of expr.templateSpans) {
|
|
22014
|
+
const value = evaluate(span.expression, location);
|
|
22015
|
+
if (value === void 0) {
|
|
22016
|
+
return void 0;
|
|
22017
|
+
}
|
|
22018
|
+
result += value;
|
|
22019
|
+
result += span.literal.text;
|
|
22020
|
+
}
|
|
22021
|
+
return result;
|
|
22022
|
+
}
|
|
22023
|
+
return evaluate;
|
|
22024
|
+
}
|
|
21938
22025
|
|
|
21939
22026
|
// src/compiler/factory/baseNodeFactory.ts
|
|
21940
22027
|
function createBaseNodeFactory() {
|
|
@@ -47346,13 +47433,21 @@ function getLocalModuleSpecifier(moduleFileName, info, compilerOptions, host, im
|
|
|
47346
47433
|
}
|
|
47347
47434
|
const nearestTargetPackageJson = getNearestAncestorDirectoryWithPackageJson(host, getDirectoryPath(modulePath));
|
|
47348
47435
|
const nearestSourcePackageJson = getNearestAncestorDirectoryWithPackageJson(host, sourceDirectory);
|
|
47349
|
-
|
|
47436
|
+
const ignoreCase = !hostUsesCaseSensitiveFileNames(host);
|
|
47437
|
+
if (!packageJsonPathsAreEqual(nearestTargetPackageJson, nearestSourcePackageJson, ignoreCase)) {
|
|
47350
47438
|
return maybeNonRelative;
|
|
47351
47439
|
}
|
|
47352
47440
|
return relativePath;
|
|
47353
47441
|
}
|
|
47354
47442
|
return isPathRelativeToParent(maybeNonRelative) || countPathComponents(relativePath) < countPathComponents(maybeNonRelative) ? relativePath : maybeNonRelative;
|
|
47355
47443
|
}
|
|
47444
|
+
function packageJsonPathsAreEqual(a, b, ignoreCase) {
|
|
47445
|
+
if (a === b)
|
|
47446
|
+
return true;
|
|
47447
|
+
if (a === void 0 || b === void 0)
|
|
47448
|
+
return false;
|
|
47449
|
+
return comparePaths(a, b, ignoreCase) === 0 /* EqualTo */;
|
|
47450
|
+
}
|
|
47356
47451
|
function countPathComponents(path) {
|
|
47357
47452
|
let count = 0;
|
|
47358
47453
|
for (let i = startsWith(path, "./") ? 2 : 0; i < path.length; i++) {
|
|
@@ -48134,6 +48229,10 @@ function createTypeChecker(host) {
|
|
|
48134
48229
|
var checkBinaryExpression = createCheckBinaryExpression();
|
|
48135
48230
|
var emitResolver = createResolver();
|
|
48136
48231
|
var nodeBuilder = createNodeBuilder();
|
|
48232
|
+
var evaluate = createEvaluator({
|
|
48233
|
+
evaluateElementAccessExpression,
|
|
48234
|
+
evaluateEntityNameExpression
|
|
48235
|
+
});
|
|
48137
48236
|
var globals = createSymbolTable();
|
|
48138
48237
|
var undefinedSymbol = createSymbol(4 /* Property */, "undefined");
|
|
48139
48238
|
undefinedSymbol.declarations = [];
|
|
@@ -52632,17 +52731,8 @@ function createTypeChecker(host) {
|
|
|
52632
52731
|
typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
|
|
52633
52732
|
typePredicateToTypePredicateNode: (typePredicate, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typePredicateToTypePredicateNodeHelper(typePredicate, context)),
|
|
52634
52733
|
expressionOrTypeToTypeNode: (expr, type, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => expressionOrTypeToTypeNode(context, expr, type, addUndefined)),
|
|
52635
|
-
serializeTypeForDeclaration: (type, symbol, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeTypeForDeclaration(
|
|
52636
|
-
|
|
52637
|
-
type,
|
|
52638
|
-
symbol,
|
|
52639
|
-
enclosingDeclaration,
|
|
52640
|
-
/*includePrivateSymbol*/
|
|
52641
|
-
void 0,
|
|
52642
|
-
/*bundled*/
|
|
52643
|
-
void 0,
|
|
52644
|
-
addUndefined
|
|
52645
|
-
)),
|
|
52734
|
+
serializeTypeForDeclaration: (type, symbol, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, addUndefined)),
|
|
52735
|
+
serializeReturnTypeForSignature: (signature, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeReturnTypeForSignature(context, signature)),
|
|
52646
52736
|
indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
|
|
52647
52737
|
indexInfo,
|
|
52648
52738
|
context,
|
|
@@ -52661,7 +52751,7 @@ function createTypeChecker(host) {
|
|
|
52661
52751
|
symbolToTypeParameterDeclarations: (symbol, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeParametersToTypeParameterDeclarations(symbol, context)),
|
|
52662
52752
|
symbolToParameterDeclaration: (symbol, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToParameterDeclaration(symbol, context)),
|
|
52663
52753
|
typeParameterToDeclaration: (parameter, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeParameterToDeclaration(parameter, context)),
|
|
52664
|
-
symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker
|
|
52754
|
+
symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context)),
|
|
52665
52755
|
symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
|
|
52666
52756
|
};
|
|
52667
52757
|
function expressionOrTypeToTypeNode(context, expr, type, addUndefined) {
|
|
@@ -52679,12 +52769,12 @@ function createTypeChecker(host) {
|
|
|
52679
52769
|
}
|
|
52680
52770
|
return typeToTypeNodeHelper(type, context);
|
|
52681
52771
|
}
|
|
52682
|
-
function tryReuseExistingTypeNode(context, typeNode, type, host2, addUndefined
|
|
52772
|
+
function tryReuseExistingTypeNode(context, typeNode, type, host2, addUndefined) {
|
|
52683
52773
|
const originalType = type;
|
|
52684
52774
|
if (addUndefined) {
|
|
52685
52775
|
type = getOptionalType(type);
|
|
52686
52776
|
}
|
|
52687
|
-
const clone2 = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2
|
|
52777
|
+
const clone2 = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2);
|
|
52688
52778
|
if (clone2) {
|
|
52689
52779
|
if (addUndefined && !someType(getTypeFromTypeNode(typeNode), (t) => !!(t.flags & 32768 /* Undefined */))) {
|
|
52690
52780
|
return factory.createUnionTypeNode([clone2, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
|
|
@@ -52692,16 +52782,16 @@ function createTypeChecker(host) {
|
|
|
52692
52782
|
return clone2;
|
|
52693
52783
|
}
|
|
52694
52784
|
if (addUndefined && originalType !== type) {
|
|
52695
|
-
const cloneMissingUndefined = tryReuseExistingNonParameterTypeNode(context, typeNode, originalType, host2
|
|
52785
|
+
const cloneMissingUndefined = tryReuseExistingNonParameterTypeNode(context, typeNode, originalType, host2);
|
|
52696
52786
|
if (cloneMissingUndefined) {
|
|
52697
52787
|
return factory.createUnionTypeNode([cloneMissingUndefined, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
|
|
52698
52788
|
}
|
|
52699
52789
|
}
|
|
52700
52790
|
return void 0;
|
|
52701
52791
|
}
|
|
52702
|
-
function tryReuseExistingNonParameterTypeNode(context, existing, type, host2 = context.enclosingDeclaration,
|
|
52792
|
+
function tryReuseExistingNonParameterTypeNode(context, existing, type, host2 = context.enclosingDeclaration, annotationType) {
|
|
52703
52793
|
if (typeNodeIsEquivalentToType(existing, host2, type, annotationType) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
|
|
52704
|
-
const result = tryReuseExistingTypeNodeHelper(context, existing
|
|
52794
|
+
const result = tryReuseExistingTypeNodeHelper(context, existing);
|
|
52705
52795
|
if (result) {
|
|
52706
52796
|
return result;
|
|
52707
52797
|
}
|
|
@@ -52736,7 +52826,8 @@ function createTypeChecker(host) {
|
|
|
52736
52826
|
symbolDepth: void 0,
|
|
52737
52827
|
inferTypeParameters: void 0,
|
|
52738
52828
|
approximateLength: 0,
|
|
52739
|
-
trackedSymbols: void 0
|
|
52829
|
+
trackedSymbols: void 0,
|
|
52830
|
+
bundled: !!compilerOptions.outFile && !!enclosingDeclaration && isExternalOrCommonJsModule(getSourceFileOfNode(enclosingDeclaration))
|
|
52740
52831
|
};
|
|
52741
52832
|
context.tracker = new SymbolTrackerImpl(context, tracker, moduleResolverHost);
|
|
52742
52833
|
const resultingNode = cb(context);
|
|
@@ -53304,7 +53395,7 @@ function createTypeChecker(host) {
|
|
|
53304
53395
|
}
|
|
53305
53396
|
const abstractSignatures = filter(resolved.constructSignatures, (signature) => !!(signature.flags & 4 /* Abstract */));
|
|
53306
53397
|
if (some(abstractSignatures)) {
|
|
53307
|
-
const types = map(abstractSignatures, getOrCreateTypeFromSignature);
|
|
53398
|
+
const types = map(abstractSignatures, (s) => getOrCreateTypeFromSignature(s));
|
|
53308
53399
|
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
|
|
53309
53400
|
// the logic in `createTypeNodesFromResolvedType`.
|
|
53310
53401
|
(context.flags & 2048 /* WriteClassExpressionAsTypeLiteral */ ? countWhere(resolved.properties, (p) => !(p.flags & 4194304 /* Prototype */)) : length(resolved.properties));
|
|
@@ -53727,9 +53818,8 @@ function createTypeChecker(host) {
|
|
|
53727
53818
|
}
|
|
53728
53819
|
function signatureToSignatureDeclarationHelper(signature, kind, context, options) {
|
|
53729
53820
|
var _a;
|
|
53730
|
-
const
|
|
53731
|
-
|
|
53732
|
-
context.flags &= ~256 /* SuppressAnyReturnType */;
|
|
53821
|
+
const flags = context.flags;
|
|
53822
|
+
context.flags &= ~256 /* SuppressAnyReturnType */;
|
|
53733
53823
|
context.approximateLength += 3;
|
|
53734
53824
|
let typeParameters;
|
|
53735
53825
|
let typeArguments;
|
|
@@ -53805,27 +53895,17 @@ function createTypeChecker(host) {
|
|
|
53805
53895
|
);
|
|
53806
53896
|
}
|
|
53807
53897
|
}
|
|
53808
|
-
const parameters = (some(expandedParams, (p) => p !== expandedParams[expandedParams.length - 1] && !!(getCheckFlags(p) & 32768 /* RestParameter */)) ? signature.parameters : expandedParams).map((parameter) => symbolToParameterDeclaration(parameter, context, kind === 176 /* Constructor
|
|
53898
|
+
const parameters = (some(expandedParams, (p) => p !== expandedParams[expandedParams.length - 1] && !!(getCheckFlags(p) & 32768 /* RestParameter */)) ? signature.parameters : expandedParams).map((parameter) => symbolToParameterDeclaration(parameter, context, kind === 176 /* Constructor */));
|
|
53809
53899
|
const thisParameter = context.flags & 33554432 /* OmitThisParameter */ ? void 0 : tryGetThisParameterDeclaration(signature, context);
|
|
53810
53900
|
if (thisParameter) {
|
|
53811
53901
|
parameters.unshift(thisParameter);
|
|
53812
53902
|
}
|
|
53813
|
-
|
|
53814
|
-
const
|
|
53815
|
-
if (typePredicate) {
|
|
53816
|
-
returnTypeNode = typePredicateToTypePredicateNodeHelper(typePredicate, context);
|
|
53817
|
-
} else {
|
|
53818
|
-
const returnType = getReturnTypeOfSignature(signature);
|
|
53819
|
-
if (returnType && !(suppressAny && isTypeAny(returnType))) {
|
|
53820
|
-
returnTypeNode = serializeReturnTypeForSignature(context, returnType, signature, options == null ? void 0 : options.privateSymbolVisitor, options == null ? void 0 : options.bundledImports);
|
|
53821
|
-
} else if (!suppressAny) {
|
|
53822
|
-
returnTypeNode = factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
53823
|
-
}
|
|
53824
|
-
}
|
|
53903
|
+
context.flags = flags;
|
|
53904
|
+
const returnTypeNode = serializeReturnTypeForSignature(context, signature);
|
|
53825
53905
|
let modifiers = options == null ? void 0 : options.modifiers;
|
|
53826
53906
|
if (kind === 185 /* ConstructorType */ && signature.flags & 4 /* Abstract */) {
|
|
53827
|
-
const
|
|
53828
|
-
modifiers = factory.createModifiersFromModifierFlags(
|
|
53907
|
+
const flags2 = modifiersToFlags(modifiers);
|
|
53908
|
+
modifiers = factory.createModifiersFromModifierFlags(flags2 | 64 /* Abstract */);
|
|
53829
53909
|
}
|
|
53830
53910
|
const node = kind === 179 /* CallSignature */ ? factory.createCallSignature(typeParameters, parameters, returnTypeNode) : kind === 180 /* ConstructSignature */ ? factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : kind === 173 /* MethodSignature */ ? factory.createMethodSignature(modifiers, (options == null ? void 0 : options.name) ?? factory.createIdentifier(""), options == null ? void 0 : options.questionToken, typeParameters, parameters, returnTypeNode) : kind === 174 /* MethodDeclaration */ ? factory.createMethodDeclaration(
|
|
53831
53911
|
modifiers,
|
|
@@ -53954,11 +54034,11 @@ function createTypeChecker(host) {
|
|
|
53954
54034
|
return getDeclarationOfKind(parameterSymbol, 341 /* JSDocParameterTag */);
|
|
53955
54035
|
}
|
|
53956
54036
|
}
|
|
53957
|
-
function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags
|
|
54037
|
+
function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags) {
|
|
53958
54038
|
const parameterDeclaration = getEffectiveParameterDeclaration(parameterSymbol);
|
|
53959
54039
|
const parameterType = getTypeOfSymbol(parameterSymbol);
|
|
53960
54040
|
const addUndefined = parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration);
|
|
53961
|
-
const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration,
|
|
54041
|
+
const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, addUndefined);
|
|
53962
54042
|
const modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && canHaveModifiers(parameterDeclaration) ? map(getModifiers(parameterDeclaration), factory.cloneNode) : void 0;
|
|
53963
54043
|
const isRest = parameterDeclaration && isRestParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
|
|
53964
54044
|
const dotDotDotToken = isRest ? factory.createToken(26 /* DotDotDotToken */) : void 0;
|
|
@@ -54527,7 +54607,7 @@ function createTypeChecker(host) {
|
|
|
54527
54607
|
return initial;
|
|
54528
54608
|
}
|
|
54529
54609
|
function getDeclarationWithTypeAnnotation(symbol, enclosingDeclaration) {
|
|
54530
|
-
return symbol.declarations && find(symbol.declarations, (s) => !!
|
|
54610
|
+
return symbol.declarations && find(symbol.declarations, (s) => !!getNonlocalEffectiveTypeAnnotationNode(s) && (!enclosingDeclaration || !!findAncestor(s, (n) => n === enclosingDeclaration)));
|
|
54531
54611
|
}
|
|
54532
54612
|
function existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type) {
|
|
54533
54613
|
return !(getObjectFlags(type) & 4 /* Reference */) || !isTypeReferenceNode(existing) || length(existing.typeArguments) >= getMinTypeArgumentCount(type.target.typeParameters);
|
|
@@ -54538,13 +54618,13 @@ function createTypeChecker(host) {
|
|
|
54538
54618
|
}
|
|
54539
54619
|
return enclosingDeclaration;
|
|
54540
54620
|
}
|
|
54541
|
-
function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration,
|
|
54621
|
+
function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, addUndefined) {
|
|
54542
54622
|
var _a;
|
|
54543
54623
|
if (!isErrorType(type) && enclosingDeclaration) {
|
|
54544
54624
|
const declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration));
|
|
54545
54625
|
if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
54546
|
-
const existing =
|
|
54547
|
-
const result2 = tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined
|
|
54626
|
+
const existing = getNonlocalEffectiveTypeAnnotationNode(declWithExistingAnnotation);
|
|
54627
|
+
const result2 = tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined);
|
|
54548
54628
|
if (result2) {
|
|
54549
54629
|
return result2;
|
|
54550
54630
|
}
|
|
@@ -54569,22 +54649,43 @@ function createTypeChecker(host) {
|
|
|
54569
54649
|
}
|
|
54570
54650
|
return false;
|
|
54571
54651
|
}
|
|
54572
|
-
function serializeReturnTypeForSignature(context,
|
|
54652
|
+
function serializeReturnTypeForSignature(context, signature) {
|
|
54653
|
+
const suppressAny = context.flags & 256 /* SuppressAnyReturnType */;
|
|
54654
|
+
const flags = context.flags;
|
|
54655
|
+
if (suppressAny)
|
|
54656
|
+
context.flags &= ~256 /* SuppressAnyReturnType */;
|
|
54657
|
+
let returnTypeNode;
|
|
54658
|
+
const returnType = getReturnTypeOfSignature(signature);
|
|
54659
|
+
if (returnType && !(suppressAny && isTypeAny(returnType))) {
|
|
54660
|
+
returnTypeNode = serializeReturnTypeForSignatureWorker(context, signature);
|
|
54661
|
+
} else if (!suppressAny) {
|
|
54662
|
+
returnTypeNode = factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
54663
|
+
}
|
|
54664
|
+
context.flags = flags;
|
|
54665
|
+
return returnTypeNode;
|
|
54666
|
+
}
|
|
54667
|
+
function serializeReturnTypeForSignatureWorker(context, signature) {
|
|
54668
|
+
const typePredicate = getTypePredicateOfSignature(signature);
|
|
54669
|
+
const type = getReturnTypeOfSignature(signature);
|
|
54573
54670
|
if (!isErrorType(type) && context.enclosingDeclaration) {
|
|
54574
|
-
const annotation = signature.declaration &&
|
|
54671
|
+
const annotation = signature.declaration && getNonlocalEffectiveReturnTypeAnnotationNode(signature.declaration);
|
|
54575
54672
|
const enclosingDeclarationIgnoringFakeScope = getEnclosingDeclarationIgnoringFakeScope(context.enclosingDeclaration);
|
|
54576
54673
|
if (!!findAncestor(annotation, (n) => n === enclosingDeclarationIgnoringFakeScope) && annotation) {
|
|
54577
54674
|
const annotated = getTypeFromTypeNode(annotation);
|
|
54578
54675
|
const thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated;
|
|
54579
|
-
const result = tryReuseExistingNonParameterTypeNode(context, annotation, type, signature.declaration,
|
|
54676
|
+
const result = tryReuseExistingNonParameterTypeNode(context, annotation, type, signature.declaration, thisInstantiated);
|
|
54580
54677
|
if (result) {
|
|
54581
54678
|
return result;
|
|
54582
54679
|
}
|
|
54583
54680
|
}
|
|
54584
54681
|
}
|
|
54585
|
-
|
|
54682
|
+
if (typePredicate) {
|
|
54683
|
+
return typePredicateToTypePredicateNodeHelper(typePredicate, context);
|
|
54684
|
+
}
|
|
54685
|
+
const expr = signature.declaration && getPossibleTypeNodeReuseExpression(signature.declaration);
|
|
54686
|
+
return expressionOrTypeToTypeNode(context, expr, type);
|
|
54586
54687
|
}
|
|
54587
|
-
function trackExistingEntityName(node, context
|
|
54688
|
+
function trackExistingEntityName(node, context) {
|
|
54588
54689
|
let introducesError = false;
|
|
54589
54690
|
const leftmost = getFirstIdentifier(node);
|
|
54590
54691
|
if (isInJSFile(node) && (isExportsIdentifier(leftmost) || isModuleExportsAccessExpression(leftmost.parent) || isQualifiedName(leftmost.parent) && isModuleIdentifier(leftmost.parent.left) && isExportsIdentifier(leftmost.parent.right))) {
|
|
@@ -54613,23 +54714,21 @@ function createTypeChecker(host) {
|
|
|
54613
54714
|
}
|
|
54614
54715
|
} else {
|
|
54615
54716
|
context.tracker.trackSymbol(sym, context.enclosingDeclaration, meaning);
|
|
54616
|
-
includePrivateSymbol == null ? void 0 : includePrivateSymbol(sym);
|
|
54617
54717
|
}
|
|
54618
54718
|
if (isIdentifier(node)) {
|
|
54619
54719
|
const type = getDeclaredTypeOfSymbol(sym);
|
|
54620
54720
|
const name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(type, context) : factory.cloneNode(node);
|
|
54621
54721
|
name.symbol = sym;
|
|
54622
|
-
return { introducesError, node: setEmitFlags(setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
|
|
54722
|
+
return { introducesError, node: setTextRange(setEmitFlags(setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */), node) };
|
|
54623
54723
|
}
|
|
54624
54724
|
}
|
|
54625
54725
|
return { introducesError, node };
|
|
54626
54726
|
}
|
|
54627
|
-
function tryReuseExistingTypeNodeHelper(context, existing
|
|
54727
|
+
function tryReuseExistingTypeNodeHelper(context, existing) {
|
|
54628
54728
|
if (cancellationToken && cancellationToken.throwIfCancellationRequested) {
|
|
54629
54729
|
cancellationToken.throwIfCancellationRequested();
|
|
54630
54730
|
}
|
|
54631
54731
|
let hadError = false;
|
|
54632
|
-
const file = getSourceFileOfNode(existing);
|
|
54633
54732
|
const transformed = visitNode(existing, visitExistingNodeTreeSymbols, isTypeNode);
|
|
54634
54733
|
if (hadError) {
|
|
54635
54734
|
return void 0;
|
|
@@ -54748,40 +54847,43 @@ function createTypeChecker(host) {
|
|
|
54748
54847
|
node.isTypeOf
|
|
54749
54848
|
);
|
|
54750
54849
|
}
|
|
54751
|
-
if (
|
|
54752
|
-
|
|
54753
|
-
return factory.updateParameterDeclaration(
|
|
54754
|
-
node,
|
|
54755
|
-
/*modifiers*/
|
|
54756
|
-
void 0,
|
|
54757
|
-
node.dotDotDotToken,
|
|
54758
|
-
visitEachChild(
|
|
54759
|
-
node.name,
|
|
54760
|
-
visitExistingNodeTreeSymbols,
|
|
54761
|
-
/*context*/
|
|
54762
|
-
void 0
|
|
54763
|
-
),
|
|
54764
|
-
node.questionToken,
|
|
54765
|
-
factory.createKeywordTypeNode(133 /* AnyKeyword */),
|
|
54766
|
-
/*initializer*/
|
|
54767
|
-
void 0
|
|
54768
|
-
);
|
|
54769
|
-
}
|
|
54850
|
+
if (isNamedDeclaration(node) && node.name.kind === 167 /* ComputedPropertyName */ && !isLateBindableName(node.name)) {
|
|
54851
|
+
return void 0;
|
|
54770
54852
|
}
|
|
54771
|
-
if (isPropertySignature(node)) {
|
|
54772
|
-
|
|
54773
|
-
|
|
54853
|
+
if (isFunctionLike(node) && !node.type || isPropertyDeclaration(node) && !node.type && !node.initializer || isPropertySignature(node) && !node.type && !node.initializer || isParameter(node) && !node.type && !node.initializer) {
|
|
54854
|
+
let visited = visitEachChild(
|
|
54855
|
+
node,
|
|
54856
|
+
visitExistingNodeTreeSymbols,
|
|
54857
|
+
/*context*/
|
|
54858
|
+
void 0
|
|
54859
|
+
);
|
|
54860
|
+
if (visited === node) {
|
|
54861
|
+
visited = setTextRange(factory.cloneNode(node), node);
|
|
54774
54862
|
}
|
|
54863
|
+
visited.type = factory.createKeywordTypeNode(133 /* AnyKeyword */);
|
|
54864
|
+
if (isParameter(node)) {
|
|
54865
|
+
visited.modifiers = void 0;
|
|
54866
|
+
}
|
|
54867
|
+
return visited;
|
|
54775
54868
|
}
|
|
54776
54869
|
if (isEntityName(node) || isEntityNameExpression(node)) {
|
|
54777
|
-
const { introducesError, node: result } = trackExistingEntityName(node, context
|
|
54870
|
+
const { introducesError, node: result } = trackExistingEntityName(node, context);
|
|
54778
54871
|
hadError = hadError || introducesError;
|
|
54779
54872
|
if (result !== node) {
|
|
54780
54873
|
return result;
|
|
54781
54874
|
}
|
|
54782
54875
|
}
|
|
54783
|
-
if (
|
|
54784
|
-
|
|
54876
|
+
if (isTupleTypeNode(node) || isTypeLiteralNode(node) || isMappedTypeNode(node)) {
|
|
54877
|
+
const visited = visitEachChild(
|
|
54878
|
+
node,
|
|
54879
|
+
visitExistingNodeTreeSymbols,
|
|
54880
|
+
/*context*/
|
|
54881
|
+
void 0
|
|
54882
|
+
);
|
|
54883
|
+
const clone2 = setTextRange(visited === node ? factory.cloneNode(node) : visited, node);
|
|
54884
|
+
const flags = getEmitFlags(clone2);
|
|
54885
|
+
setEmitFlags(clone2, flags | (context.flags & 1024 /* MultilineObjectLiterals */ && isTypeLiteralNode(node) ? 0 : 1 /* SingleLine */));
|
|
54886
|
+
return clone2;
|
|
54785
54887
|
}
|
|
54786
54888
|
return visitEachChild(
|
|
54787
54889
|
node,
|
|
@@ -54796,7 +54898,7 @@ function createTypeChecker(host) {
|
|
|
54796
54898
|
return p.name && isIdentifier(p.name) && p.name.escapedText === "this" ? "this" : getEffectiveDotDotDotForParameter(p) ? `args` : `arg${index}`;
|
|
54797
54899
|
}
|
|
54798
54900
|
function rewriteModuleSpecifier(parent2, lit) {
|
|
54799
|
-
if (bundled) {
|
|
54901
|
+
if (context.bundled) {
|
|
54800
54902
|
if (context.tracker && context.tracker.moduleResolverHost) {
|
|
54801
54903
|
const targetFile = getExternalModuleFileFromDeclaration(parent2);
|
|
54802
54904
|
if (targetFile) {
|
|
@@ -54815,7 +54917,7 @@ function createTypeChecker(host) {
|
|
|
54815
54917
|
}
|
|
54816
54918
|
}
|
|
54817
54919
|
}
|
|
54818
|
-
function symbolTableToDeclarationStatements(symbolTable, context
|
|
54920
|
+
function symbolTableToDeclarationStatements(symbolTable, context) {
|
|
54819
54921
|
var _a;
|
|
54820
54922
|
const serializePropertySymbolForClass = makeSerializePropertySymbol(
|
|
54821
54923
|
factory.createPropertyDeclaration,
|
|
@@ -54874,7 +54976,7 @@ function createTypeChecker(host) {
|
|
|
54874
54976
|
const baseName = unescapeLeadingUnderscores(name);
|
|
54875
54977
|
void getInternalSymbolName(symbol, baseName);
|
|
54876
54978
|
});
|
|
54877
|
-
let addingDeclare = !bundled;
|
|
54979
|
+
let addingDeclare = !context.bundled;
|
|
54878
54980
|
const exportEquals = symbolTable.get("export=" /* ExportEquals */);
|
|
54879
54981
|
if (exportEquals && symbolTable.size > 1 && exportEquals.flags & (2097152 /* Alias */ | 1536 /* Module */)) {
|
|
54880
54982
|
symbolTable = createSymbolTable();
|
|
@@ -55155,7 +55257,7 @@ function createTypeChecker(host) {
|
|
|
55155
55257
|
name,
|
|
55156
55258
|
/*exclamationToken*/
|
|
55157
55259
|
void 0,
|
|
55158
|
-
serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration
|
|
55260
|
+
serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration)
|
|
55159
55261
|
)
|
|
55160
55262
|
], flags)
|
|
55161
55263
|
),
|
|
@@ -55297,9 +55399,7 @@ function createTypeChecker(host) {
|
|
|
55297
55399
|
jsdocAliasDecl.typeExpression.type,
|
|
55298
55400
|
aliasType,
|
|
55299
55401
|
/*host*/
|
|
55300
|
-
void 0
|
|
55301
|
-
includePrivateSymbol,
|
|
55302
|
-
bundled
|
|
55402
|
+
void 0
|
|
55303
55403
|
) || typeToTypeNodeHelper(aliasType, context);
|
|
55304
55404
|
addResult(
|
|
55305
55405
|
setSyntheticLeadingComments(
|
|
@@ -55429,7 +55529,7 @@ function createTypeChecker(host) {
|
|
|
55429
55529
|
function serializeAsFunctionNamespaceMerge(type, symbol, localName, modifierFlags) {
|
|
55430
55530
|
const signatures = getSignaturesOfType(type, 0 /* Call */);
|
|
55431
55531
|
for (const sig of signatures) {
|
|
55432
|
-
const decl = signatureToSignatureDeclarationHelper(sig, 262 /* FunctionDeclaration */, context, { name: factory.createIdentifier(localName)
|
|
55532
|
+
const decl = signatureToSignatureDeclarationHelper(sig, 262 /* FunctionDeclaration */, context, { name: factory.createIdentifier(localName) });
|
|
55433
55533
|
addResult(setTextRange(decl, getSignatureTextRangeLocation(sig)), modifierFlags);
|
|
55434
55534
|
}
|
|
55435
55535
|
if (!(symbol.flags & (512 /* ValueModule */ | 1024 /* NamespaceModule */) && !!symbol.exports && !!symbol.exports.size)) {
|
|
@@ -55523,7 +55623,7 @@ function createTypeChecker(host) {
|
|
|
55523
55623
|
);
|
|
55524
55624
|
}
|
|
55525
55625
|
let introducesError;
|
|
55526
|
-
({ introducesError, node: expr } = trackExistingEntityName(expr, context
|
|
55626
|
+
({ introducesError, node: expr } = trackExistingEntityName(expr, context));
|
|
55527
55627
|
if (introducesError) {
|
|
55528
55628
|
return cleanup(
|
|
55529
55629
|
/*result*/
|
|
@@ -55533,15 +55633,7 @@ function createTypeChecker(host) {
|
|
|
55533
55633
|
}
|
|
55534
55634
|
return cleanup(factory.createExpressionWithTypeArguments(
|
|
55535
55635
|
expr,
|
|
55536
|
-
map(e.typeArguments, (a) => tryReuseExistingNonParameterTypeNode(
|
|
55537
|
-
context,
|
|
55538
|
-
a,
|
|
55539
|
-
getTypeFromTypeNode(a),
|
|
55540
|
-
/*host*/
|
|
55541
|
-
void 0,
|
|
55542
|
-
includePrivateSymbol,
|
|
55543
|
-
bundled
|
|
55544
|
-
) || typeToTypeNodeHelper(getTypeFromTypeNode(a), context))
|
|
55636
|
+
map(e.typeArguments, (a) => tryReuseExistingNonParameterTypeNode(context, a, getTypeFromTypeNode(a)) || typeToTypeNodeHelper(getTypeFromTypeNode(a), context))
|
|
55545
55637
|
));
|
|
55546
55638
|
function cleanup(result2) {
|
|
55547
55639
|
context.enclosingDeclaration = oldEnclosing;
|
|
@@ -55766,7 +55858,7 @@ function createTypeChecker(host) {
|
|
|
55766
55858
|
break;
|
|
55767
55859
|
case 273 /* ImportClause */: {
|
|
55768
55860
|
const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
|
|
55769
|
-
const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.moduleSpecifier;
|
|
55861
|
+
const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.moduleSpecifier;
|
|
55770
55862
|
const attributes = isImportDeclaration(node.parent) ? node.parent.attributes : void 0;
|
|
55771
55863
|
const isTypeOnly = isJSDocImportTag(node.parent);
|
|
55772
55864
|
addResult(
|
|
@@ -55788,7 +55880,7 @@ function createTypeChecker(host) {
|
|
|
55788
55880
|
}
|
|
55789
55881
|
case 274 /* NamespaceImport */: {
|
|
55790
55882
|
const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
|
|
55791
|
-
const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.moduleSpecifier;
|
|
55883
|
+
const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.moduleSpecifier;
|
|
55792
55884
|
const isTypeOnly = isJSDocImportTag(node.parent.parent);
|
|
55793
55885
|
addResult(
|
|
55794
55886
|
factory.createImportDeclaration(
|
|
@@ -55822,7 +55914,7 @@ function createTypeChecker(host) {
|
|
|
55822
55914
|
break;
|
|
55823
55915
|
case 276 /* ImportSpecifier */: {
|
|
55824
55916
|
const generatedSpecifier = getSpecifierForModuleSymbol(target.parent || target, context);
|
|
55825
|
-
const specifier2 = bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.parent.moduleSpecifier;
|
|
55917
|
+
const specifier2 = context.bundled ? factory.createStringLiteral(generatedSpecifier) : node.parent.parent.parent.moduleSpecifier;
|
|
55826
55918
|
const isTypeOnly = isJSDocImportTag(node.parent.parent.parent);
|
|
55827
55919
|
addResult(
|
|
55828
55920
|
factory.createImportDeclaration(
|
|
@@ -55976,7 +56068,7 @@ function createTypeChecker(host) {
|
|
|
55976
56068
|
varName,
|
|
55977
56069
|
/*exclamationToken*/
|
|
55978
56070
|
void 0,
|
|
55979
|
-
serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration
|
|
56071
|
+
serializeTypeForDeclaration(context, typeToSerialize, symbol, enclosingDeclaration)
|
|
55980
56072
|
)
|
|
55981
56073
|
], flags)
|
|
55982
56074
|
);
|
|
@@ -56060,7 +56152,7 @@ function createTypeChecker(host) {
|
|
|
56060
56152
|
paramSymbol ? parameterToParameterDeclarationName(paramSymbol, getEffectiveParameterDeclaration(paramSymbol), context) : "value",
|
|
56061
56153
|
/*questionToken*/
|
|
56062
56154
|
void 0,
|
|
56063
|
-
isPrivate ? void 0 : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration
|
|
56155
|
+
isPrivate ? void 0 : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration)
|
|
56064
56156
|
)],
|
|
56065
56157
|
/*body*/
|
|
56066
56158
|
void 0
|
|
@@ -56075,7 +56167,7 @@ function createTypeChecker(host) {
|
|
|
56075
56167
|
factory.createModifiersFromModifierFlags(flag),
|
|
56076
56168
|
name,
|
|
56077
56169
|
[],
|
|
56078
|
-
isPrivate2 ? void 0 : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration
|
|
56170
|
+
isPrivate2 ? void 0 : serializeTypeForDeclaration(context, getTypeOfSymbol(p), p, enclosingDeclaration),
|
|
56079
56171
|
/*body*/
|
|
56080
56172
|
void 0
|
|
56081
56173
|
),
|
|
@@ -56089,7 +56181,7 @@ function createTypeChecker(host) {
|
|
|
56089
56181
|
factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? 8 /* Readonly */ : 0) | flag),
|
|
56090
56182
|
name,
|
|
56091
56183
|
p.flags & 16777216 /* Optional */ ? factory.createToken(58 /* QuestionToken */) : void 0,
|
|
56092
|
-
isPrivate ? void 0 : serializeTypeForDeclaration(context, getWriteTypeOfSymbol(p), p, enclosingDeclaration
|
|
56184
|
+
isPrivate ? void 0 : serializeTypeForDeclaration(context, getWriteTypeOfSymbol(p), p, enclosingDeclaration),
|
|
56093
56185
|
// TODO: https://github.com/microsoft/TypeScript/pull/32372#discussion_r328386357
|
|
56094
56186
|
// interface members can't have initializers, however class members _can_
|
|
56095
56187
|
/*initializer*/
|
|
@@ -59461,11 +59553,15 @@ function createTypeChecker(host) {
|
|
|
59461
59553
|
const modifiers = getMappedTypeModifiers(type);
|
|
59462
59554
|
return modifiers & 8 /* ExcludeOptional */ ? -1 : modifiers & 4 /* IncludeOptional */ ? 1 : 0;
|
|
59463
59555
|
}
|
|
59464
|
-
function getModifiersTypeOptionality(type) {
|
|
59465
|
-
return type.flags & 2097152 /* Intersection */ ? Math.max(...map(type.types, getModifiersTypeOptionality)) : getObjectFlags(type) & 32 /* Mapped */ ? getCombinedMappedTypeOptionality(type) : 0;
|
|
59466
|
-
}
|
|
59467
59556
|
function getCombinedMappedTypeOptionality(type) {
|
|
59468
|
-
|
|
59557
|
+
if (getObjectFlags(type) & 32 /* Mapped */) {
|
|
59558
|
+
return getMappedTypeOptionality(type) || getCombinedMappedTypeOptionality(getModifiersTypeFromMappedType(type));
|
|
59559
|
+
}
|
|
59560
|
+
if (type.flags & 2097152 /* Intersection */) {
|
|
59561
|
+
const optionality = getCombinedMappedTypeOptionality(type.types[0]);
|
|
59562
|
+
return every(type.types, (t, i) => i === 0 || getCombinedMappedTypeOptionality(t) === optionality) ? optionality : 0;
|
|
59563
|
+
}
|
|
59564
|
+
return 0;
|
|
59469
59565
|
}
|
|
59470
59566
|
function isPartialMappedType(type) {
|
|
59471
59567
|
return !!(getObjectFlags(type) & 32 /* Mapped */ && getMappedTypeModifiers(type) & 4 /* IncludeOptional */);
|
|
@@ -60742,6 +60838,12 @@ function createTypeChecker(host) {
|
|
|
60742
60838
|
isInJSFile(signature.declaration)
|
|
60743
60839
|
);
|
|
60744
60840
|
}
|
|
60841
|
+
function getImplementationSignature(signature) {
|
|
60842
|
+
return signature.typeParameters ? signature.implementationSignatureCache || (signature.implementationSignatureCache = createImplementationSignature(signature)) : signature;
|
|
60843
|
+
}
|
|
60844
|
+
function createImplementationSignature(signature) {
|
|
60845
|
+
return signature.typeParameters ? instantiateSignature(signature, createTypeMapper([], [])) : signature;
|
|
60846
|
+
}
|
|
60745
60847
|
function getBaseSignature(signature) {
|
|
60746
60848
|
const typeParameters = signature.typeParameters;
|
|
60747
60849
|
if (typeParameters) {
|
|
@@ -60764,12 +60866,22 @@ function createTypeChecker(host) {
|
|
|
60764
60866
|
}
|
|
60765
60867
|
return signature;
|
|
60766
60868
|
}
|
|
60767
|
-
function getOrCreateTypeFromSignature(signature) {
|
|
60869
|
+
function getOrCreateTypeFromSignature(signature, outerTypeParameters) {
|
|
60768
60870
|
var _a;
|
|
60769
60871
|
if (!signature.isolatedSignatureType) {
|
|
60770
60872
|
const kind = (_a = signature.declaration) == null ? void 0 : _a.kind;
|
|
60771
60873
|
const isConstructor = kind === void 0 || kind === 176 /* Constructor */ || kind === 180 /* ConstructSignature */ || kind === 185 /* ConstructorType */;
|
|
60772
|
-
const type = createObjectType(16 /* Anonymous */);
|
|
60874
|
+
const type = createObjectType(16 /* Anonymous */ | 134217728 /* SingleSignatureType */, createSymbol(16 /* Function */, "__function" /* Function */));
|
|
60875
|
+
if (signature.declaration && !nodeIsSynthesized(signature.declaration)) {
|
|
60876
|
+
type.symbol.declarations = [signature.declaration];
|
|
60877
|
+
type.symbol.valueDeclaration = signature.declaration;
|
|
60878
|
+
}
|
|
60879
|
+
outerTypeParameters || (outerTypeParameters = signature.declaration && getOuterTypeParameters(
|
|
60880
|
+
signature.declaration,
|
|
60881
|
+
/*includeThisTypes*/
|
|
60882
|
+
true
|
|
60883
|
+
));
|
|
60884
|
+
type.outerTypeParameters = outerTypeParameters;
|
|
60773
60885
|
type.members = emptySymbols;
|
|
60774
60886
|
type.properties = emptyArray;
|
|
60775
60887
|
type.callSignatures = !isConstructor ? [signature] : emptyArray;
|
|
@@ -63258,13 +63370,18 @@ function createTypeChecker(host) {
|
|
|
63258
63370
|
const mapper = createTypeMapper([getTypeParameterFromMappedType(objectType)], [index]);
|
|
63259
63371
|
const templateMapper = combineTypeMappers(objectType.mapper, mapper);
|
|
63260
63372
|
const instantiatedTemplateType = instantiateType(getTemplateTypeFromMappedType(objectType.target || objectType), templateMapper);
|
|
63373
|
+
const isOptional = getMappedTypeOptionality(objectType) > 0 || (isGenericType(objectType) ? getCombinedMappedTypeOptionality(getModifiersTypeFromMappedType(objectType)) > 0 : couldAccessOptionalProperty(objectType, index));
|
|
63261
63374
|
return addOptionality(
|
|
63262
63375
|
instantiatedTemplateType,
|
|
63263
63376
|
/*isProperty*/
|
|
63264
63377
|
true,
|
|
63265
|
-
|
|
63378
|
+
isOptional
|
|
63266
63379
|
);
|
|
63267
63380
|
}
|
|
63381
|
+
function couldAccessOptionalProperty(objectType, indexType) {
|
|
63382
|
+
const indexConstraint = getBaseConstraintOfType(indexType);
|
|
63383
|
+
return !!indexConstraint && some(getPropertiesOfType(objectType), (p) => !!(p.flags & 16777216 /* Optional */) && isTypeAssignableTo(getLiteralTypeFromProperty(p, 8576 /* StringOrNumberLiteralOrUnique */), indexConstraint));
|
|
63384
|
+
}
|
|
63268
63385
|
function getIndexedAccessType(objectType, indexType, accessFlags = 0 /* None */, accessNode, aliasSymbol, aliasTypeArguments) {
|
|
63269
63386
|
return getIndexedAccessTypeOrUndefined(objectType, indexType, accessFlags, accessNode, aliasSymbol, aliasTypeArguments) || (accessNode ? errorType : unknownType);
|
|
63270
63387
|
}
|
|
@@ -64175,7 +64292,7 @@ function createTypeChecker(host) {
|
|
|
64175
64292
|
const declaration = type.objectFlags & 4 /* Reference */ ? type.node : type.objectFlags & 8388608 /* InstantiationExpressionType */ ? type.node : type.symbol.declarations[0];
|
|
64176
64293
|
const links = getNodeLinks(declaration);
|
|
64177
64294
|
const target = type.objectFlags & 4 /* Reference */ ? links.resolvedType : type.objectFlags & 64 /* Instantiated */ ? type.target : type;
|
|
64178
|
-
let typeParameters = links.outerTypeParameters;
|
|
64295
|
+
let typeParameters = type.objectFlags & 134217728 /* SingleSignatureType */ ? type.outerTypeParameters : links.outerTypeParameters;
|
|
64179
64296
|
if (!typeParameters) {
|
|
64180
64297
|
let outerTypeParameters = getOuterTypeParameters(
|
|
64181
64298
|
declaration,
|
|
@@ -64355,6 +64472,9 @@ function createTypeChecker(host) {
|
|
|
64355
64472
|
if (type.objectFlags & 8388608 /* InstantiationExpressionType */) {
|
|
64356
64473
|
result.node = type.node;
|
|
64357
64474
|
}
|
|
64475
|
+
if (type.objectFlags & 134217728 /* SingleSignatureType */) {
|
|
64476
|
+
result.outerTypeParameters = type.outerTypeParameters;
|
|
64477
|
+
}
|
|
64358
64478
|
result.target = type;
|
|
64359
64479
|
result.mapper = mapper;
|
|
64360
64480
|
result.aliasSymbol = aliasSymbol || type.aliasSymbol;
|
|
@@ -68986,7 +69106,7 @@ function createTypeChecker(host) {
|
|
|
68986
69106
|
if (objectFlags & 524288 /* CouldContainTypeVariablesComputed */) {
|
|
68987
69107
|
return !!(objectFlags & 1048576 /* CouldContainTypeVariables */);
|
|
68988
69108
|
}
|
|
68989
|
-
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));
|
|
69109
|
+
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));
|
|
68990
69110
|
if (type.flags & 3899393 /* ObjectFlagsType */) {
|
|
68991
69111
|
type.objectFlags |= 524288 /* CouldContainTypeVariablesComputed */ | (result ? 1048576 /* CouldContainTypeVariables */ : 0);
|
|
68992
69112
|
}
|
|
@@ -69270,6 +69390,9 @@ function createTypeChecker(host) {
|
|
|
69270
69390
|
pos = p;
|
|
69271
69391
|
}
|
|
69272
69392
|
}
|
|
69393
|
+
function isTupleOfSelf(typeParameter, type) {
|
|
69394
|
+
return isTupleType(type) && getTupleElementType(type, 0) === getIndexedAccessType(typeParameter, getNumberLiteralType(0)) && !getTypeOfPropertyOfType(type, "1");
|
|
69395
|
+
}
|
|
69273
69396
|
function inferTypes(inferences, originalSource, originalTarget, priority = 0 /* None */, contravariant = false) {
|
|
69274
69397
|
let bivariant = false;
|
|
69275
69398
|
let propagationType;
|
|
@@ -69355,6 +69478,9 @@ function createTypeChecker(host) {
|
|
|
69355
69478
|
inference.priority = priority;
|
|
69356
69479
|
}
|
|
69357
69480
|
if (priority === inference.priority) {
|
|
69481
|
+
if (isTupleOfSelf(inference.typeParameter, candidate)) {
|
|
69482
|
+
return;
|
|
69483
|
+
}
|
|
69358
69484
|
if (contravariant && !bivariant) {
|
|
69359
69485
|
if (!contains(inference.contraCandidates, candidate)) {
|
|
69360
69486
|
inference.contraCandidates = append(inference.contraCandidates, candidate);
|
|
@@ -76293,7 +76419,7 @@ function createTypeChecker(host) {
|
|
|
76293
76419
|
argument = skipParentheses(argument);
|
|
76294
76420
|
return isSatisfiesExpression(argument) ? skipParentheses(argument.expression) : argument;
|
|
76295
76421
|
}
|
|
76296
|
-
function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors2, containingMessageChain) {
|
|
76422
|
+
function getSignatureApplicabilityError(node, args, signature, relation, checkMode, reportErrors2, containingMessageChain, inferenceContext) {
|
|
76297
76423
|
const errorOutputContainer = { errors: void 0, skipLogging: true };
|
|
76298
76424
|
if (isJsxOpeningLikeElement(node)) {
|
|
76299
76425
|
if (!checkApplicableSignatureForJsxOpeningLikeElement(node, signature, relation, checkMode, reportErrors2, containingMessageChain, errorOutputContainer)) {
|
|
@@ -76327,7 +76453,8 @@ function createTypeChecker(host) {
|
|
|
76327
76453
|
void 0,
|
|
76328
76454
|
checkMode
|
|
76329
76455
|
);
|
|
76330
|
-
const
|
|
76456
|
+
const regularArgType = checkMode & 4 /* SkipContextSensitive */ ? getRegularTypeOfObjectLiteral(argType) : argType;
|
|
76457
|
+
const checkArgType = inferenceContext ? instantiateType(regularArgType, inferenceContext.nonFixingMapper) : regularArgType;
|
|
76331
76458
|
const effectiveCheckArgumentNode = getEffectiveCheckNode(arg);
|
|
76332
76459
|
if (!checkTypeRelatedToAndOptionallyElaborate(checkArgType, paramType, relation, reportErrors2 ? effectiveCheckArgumentNode : void 0, effectiveCheckArgumentNode, headMessage, containingMessageChain, errorOutputContainer)) {
|
|
76333
76460
|
Debug.assert(!reportErrors2 || !!errorOutputContainer.errors, "parameter should have errors when reporting errors");
|
|
@@ -76739,7 +76866,9 @@ function createTypeChecker(host) {
|
|
|
76739
76866
|
0 /* Normal */,
|
|
76740
76867
|
/*reportErrors*/
|
|
76741
76868
|
true,
|
|
76742
|
-
() => chain
|
|
76869
|
+
() => chain,
|
|
76870
|
+
/*inferenceContext*/
|
|
76871
|
+
void 0
|
|
76743
76872
|
);
|
|
76744
76873
|
if (diags) {
|
|
76745
76874
|
for (const d of diags) {
|
|
@@ -76775,7 +76904,9 @@ function createTypeChecker(host) {
|
|
|
76775
76904
|
0 /* Normal */,
|
|
76776
76905
|
/*reportErrors*/
|
|
76777
76906
|
true,
|
|
76778
|
-
chain2
|
|
76907
|
+
chain2,
|
|
76908
|
+
/*inferenceContext*/
|
|
76909
|
+
void 0
|
|
76779
76910
|
);
|
|
76780
76911
|
if (diags2) {
|
|
76781
76912
|
if (diags2.length <= min2) {
|
|
@@ -76866,6 +76997,8 @@ function createTypeChecker(host) {
|
|
|
76866
76997
|
/*reportErrors*/
|
|
76867
76998
|
false,
|
|
76868
76999
|
/*containingMessageChain*/
|
|
77000
|
+
void 0,
|
|
77001
|
+
/*inferenceContext*/
|
|
76869
77002
|
void 0
|
|
76870
77003
|
)) {
|
|
76871
77004
|
candidatesForArgumentError = [candidate];
|
|
@@ -76874,13 +77007,16 @@ function createTypeChecker(host) {
|
|
|
76874
77007
|
return candidate;
|
|
76875
77008
|
}
|
|
76876
77009
|
for (let candidateIndex = 0; candidateIndex < candidates2.length; candidateIndex++) {
|
|
76877
|
-
|
|
77010
|
+
let candidate = candidates2[candidateIndex];
|
|
76878
77011
|
if (!hasCorrectTypeArgumentArity(candidate, typeArguments) || !hasCorrectArity(node, args, candidate, signatureHelpTrailingComma2)) {
|
|
76879
77012
|
continue;
|
|
76880
77013
|
}
|
|
76881
77014
|
let checkCandidate;
|
|
76882
77015
|
let inferenceContext;
|
|
76883
77016
|
if (candidate.typeParameters) {
|
|
77017
|
+
if (candidate.declaration && findAncestor(node, (a) => a === candidate.declaration)) {
|
|
77018
|
+
candidate = getImplementationSignature(candidate);
|
|
77019
|
+
}
|
|
76884
77020
|
let typeArgumentTypes;
|
|
76885
77021
|
if (some(typeArguments)) {
|
|
76886
77022
|
typeArgumentTypes = checkTypeArguments(
|
|
@@ -76900,7 +77036,7 @@ function createTypeChecker(host) {
|
|
|
76900
77036
|
/*flags*/
|
|
76901
77037
|
isInJSFile(node) ? 2 /* AnyDefault */ : 0 /* None */
|
|
76902
77038
|
);
|
|
76903
|
-
typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext);
|
|
77039
|
+
typeArgumentTypes = instantiateTypes(inferTypeArguments(node, candidate, args, argCheckMode | 8 /* SkipGenericFunctions */, inferenceContext), inferenceContext.nonFixingMapper);
|
|
76904
77040
|
argCheckMode |= inferenceContext.flags & 4 /* SkippedGenericFunction */ ? 8 /* SkipGenericFunctions */ : 0 /* Normal */;
|
|
76905
77041
|
}
|
|
76906
77042
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
|
|
@@ -76920,7 +77056,8 @@ function createTypeChecker(host) {
|
|
|
76920
77056
|
/*reportErrors*/
|
|
76921
77057
|
false,
|
|
76922
77058
|
/*containingMessageChain*/
|
|
76923
|
-
void 0
|
|
77059
|
+
void 0,
|
|
77060
|
+
inferenceContext
|
|
76924
77061
|
)) {
|
|
76925
77062
|
(candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
|
|
76926
77063
|
continue;
|
|
@@ -76928,7 +77065,7 @@ function createTypeChecker(host) {
|
|
|
76928
77065
|
if (argCheckMode) {
|
|
76929
77066
|
argCheckMode = 0 /* Normal */;
|
|
76930
77067
|
if (inferenceContext) {
|
|
76931
|
-
const typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
|
|
77068
|
+
const typeArgumentTypes = instantiateTypes(inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext), inferenceContext.mapper);
|
|
76932
77069
|
checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, isInJSFile(candidate.declaration), inferenceContext.inferredTypeParameters);
|
|
76933
77070
|
if (getNonArrayRestType(candidate) && !hasCorrectArity(node, args, checkCandidate, signatureHelpTrailingComma2)) {
|
|
76934
77071
|
candidateForArgumentArityError = checkCandidate;
|
|
@@ -76944,7 +77081,8 @@ function createTypeChecker(host) {
|
|
|
76944
77081
|
/*reportErrors*/
|
|
76945
77082
|
false,
|
|
76946
77083
|
/*containingMessageChain*/
|
|
76947
|
-
void 0
|
|
77084
|
+
void 0,
|
|
77085
|
+
inferenceContext
|
|
76948
77086
|
)) {
|
|
76949
77087
|
(candidatesForArgumentError || (candidatesForArgumentError = [])).push(checkCandidate);
|
|
76950
77088
|
continue;
|
|
@@ -80484,7 +80622,7 @@ function createTypeChecker(host) {
|
|
|
80484
80622
|
) || unknownType, isTemplateLiteralContextualType)) {
|
|
80485
80623
|
return getTemplateLiteralType(texts, types);
|
|
80486
80624
|
}
|
|
80487
|
-
const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ &&
|
|
80625
|
+
const evaluated = node.parent.kind !== 215 /* TaggedTemplateExpression */ && evaluate(node);
|
|
80488
80626
|
return evaluated ? getFreshTypeOfLiteralType(getStringLiteralType(evaluated)) : stringType;
|
|
80489
80627
|
}
|
|
80490
80628
|
function isTemplateLiteralContextualType(type) {
|
|
@@ -80698,7 +80836,7 @@ function createTypeChecker(host) {
|
|
|
80698
80836
|
}
|
|
80699
80837
|
}
|
|
80700
80838
|
}
|
|
80701
|
-
return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context));
|
|
80839
|
+
return getOrCreateTypeFromSignature(instantiateSignatureInContextOf(signature, contextualSignature, context), flatMap(inferenceContexts, (c) => c && map(c.inferences, (i) => i.typeParameter)).slice());
|
|
80702
80840
|
}
|
|
80703
80841
|
}
|
|
80704
80842
|
}
|
|
@@ -80873,7 +81011,8 @@ function createTypeChecker(host) {
|
|
|
80873
81011
|
if (getIsolatedModules(compilerOptions)) {
|
|
80874
81012
|
Debug.assert(!!(type.symbol.flags & 128 /* ConstEnum */));
|
|
80875
81013
|
const constEnumDeclaration = type.symbol.valueDeclaration;
|
|
80876
|
-
|
|
81014
|
+
const redirect = host.getRedirectReferenceForResolutionFromSourceOfProject(getSourceFileOfNode(constEnumDeclaration).resolvedPath);
|
|
81015
|
+
if (constEnumDeclaration.flags & 33554432 /* Ambient */ && !isValidTypeOnlyAliasUseSite(node) && (!redirect || !shouldPreserveConstEnums(redirect.commandLine.options))) {
|
|
80877
81016
|
error2(node, Diagnostics.Cannot_access_ambient_const_enums_when_0_is_enabled, isolatedModulesLikeFlagName);
|
|
80878
81017
|
}
|
|
80879
81018
|
}
|
|
@@ -85460,122 +85599,53 @@ function createTypeChecker(host) {
|
|
|
85460
85599
|
}
|
|
85461
85600
|
return false;
|
|
85462
85601
|
}
|
|
85463
|
-
function
|
|
85464
|
-
|
|
85465
|
-
|
|
85466
|
-
|
|
85467
|
-
|
|
85468
|
-
|
|
85469
|
-
|
|
85470
|
-
|
|
85471
|
-
|
|
85472
|
-
|
|
85473
|
-
|
|
85474
|
-
|
|
85475
|
-
|
|
85476
|
-
|
|
85477
|
-
|
|
85478
|
-
|
|
85479
|
-
|
|
85480
|
-
|
|
85481
|
-
if (typeof left === "number" && typeof right === "number") {
|
|
85482
|
-
switch (expr.operatorToken.kind) {
|
|
85483
|
-
case 52 /* BarToken */:
|
|
85484
|
-
return left | right;
|
|
85485
|
-
case 51 /* AmpersandToken */:
|
|
85486
|
-
return left & right;
|
|
85487
|
-
case 49 /* GreaterThanGreaterThanToken */:
|
|
85488
|
-
return left >> right;
|
|
85489
|
-
case 50 /* GreaterThanGreaterThanGreaterThanToken */:
|
|
85490
|
-
return left >>> right;
|
|
85491
|
-
case 48 /* LessThanLessThanToken */:
|
|
85492
|
-
return left << right;
|
|
85493
|
-
case 53 /* CaretToken */:
|
|
85494
|
-
return left ^ right;
|
|
85495
|
-
case 42 /* AsteriskToken */:
|
|
85496
|
-
return left * right;
|
|
85497
|
-
case 44 /* SlashToken */:
|
|
85498
|
-
return left / right;
|
|
85499
|
-
case 40 /* PlusToken */:
|
|
85500
|
-
return left + right;
|
|
85501
|
-
case 41 /* MinusToken */:
|
|
85502
|
-
return left - right;
|
|
85503
|
-
case 45 /* PercentToken */:
|
|
85504
|
-
return left % right;
|
|
85505
|
-
case 43 /* AsteriskAsteriskToken */:
|
|
85506
|
-
return left ** right;
|
|
85507
|
-
}
|
|
85508
|
-
} else if ((typeof left === "string" || typeof left === "number") && (typeof right === "string" || typeof right === "number") && expr.operatorToken.kind === 40 /* PlusToken */) {
|
|
85509
|
-
return "" + left + right;
|
|
85510
|
-
}
|
|
85511
|
-
break;
|
|
85512
|
-
case 11 /* StringLiteral */:
|
|
85513
|
-
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
85514
|
-
return expr.text;
|
|
85515
|
-
case 228 /* TemplateExpression */:
|
|
85516
|
-
return evaluateTemplateExpression(expr, location);
|
|
85517
|
-
case 9 /* NumericLiteral */:
|
|
85518
|
-
checkGrammarNumericLiteral(expr);
|
|
85519
|
-
return +expr.text;
|
|
85520
|
-
case 217 /* ParenthesizedExpression */:
|
|
85521
|
-
return evaluate(expr.expression, location);
|
|
85522
|
-
case 80 /* Identifier */: {
|
|
85523
|
-
const identifier = expr;
|
|
85524
|
-
if (isInfinityOrNaNString(identifier.escapedText) && resolveEntityName(
|
|
85525
|
-
identifier,
|
|
85526
|
-
111551 /* Value */,
|
|
85527
|
-
/*ignoreErrors*/
|
|
85528
|
-
true
|
|
85529
|
-
) === getGlobalSymbol(
|
|
85530
|
-
identifier.escapedText,
|
|
85531
|
-
111551 /* Value */,
|
|
85532
|
-
/*diagnostic*/
|
|
85533
|
-
void 0
|
|
85534
|
-
)) {
|
|
85535
|
-
return +identifier.escapedText;
|
|
85536
|
-
}
|
|
85602
|
+
function evaluateEntityNameExpression(expr, location) {
|
|
85603
|
+
const symbol = resolveEntityName(
|
|
85604
|
+
expr,
|
|
85605
|
+
111551 /* Value */,
|
|
85606
|
+
/*ignoreErrors*/
|
|
85607
|
+
true
|
|
85608
|
+
);
|
|
85609
|
+
if (!symbol)
|
|
85610
|
+
return void 0;
|
|
85611
|
+
if (expr.kind === 80 /* Identifier */) {
|
|
85612
|
+
const identifier = expr;
|
|
85613
|
+
if (isInfinityOrNaNString(identifier.escapedText) && symbol === getGlobalSymbol(
|
|
85614
|
+
identifier.escapedText,
|
|
85615
|
+
111551 /* Value */,
|
|
85616
|
+
/*diagnostic*/
|
|
85617
|
+
void 0
|
|
85618
|
+
)) {
|
|
85619
|
+
return +identifier.escapedText;
|
|
85537
85620
|
}
|
|
85538
|
-
|
|
85539
|
-
|
|
85540
|
-
|
|
85541
|
-
|
|
85542
|
-
|
|
85543
|
-
|
|
85544
|
-
|
|
85545
|
-
|
|
85546
|
-
|
|
85547
|
-
|
|
85548
|
-
|
|
85549
|
-
|
|
85550
|
-
|
|
85551
|
-
|
|
85552
|
-
|
|
85553
|
-
|
|
85554
|
-
|
|
85555
|
-
|
|
85556
|
-
|
|
85557
|
-
|
|
85558
|
-
|
|
85559
|
-
|
|
85560
|
-
const
|
|
85561
|
-
if (
|
|
85562
|
-
|
|
85563
|
-
root,
|
|
85564
|
-
111551 /* Value */,
|
|
85565
|
-
/*ignoreErrors*/
|
|
85566
|
-
true
|
|
85567
|
-
);
|
|
85568
|
-
if (rootSymbol && rootSymbol.flags & 384 /* Enum */) {
|
|
85569
|
-
const name = escapeLeadingUnderscores(expr.argumentExpression.text);
|
|
85570
|
-
const member = rootSymbol.exports.get(name);
|
|
85571
|
-
if (member) {
|
|
85572
|
-
return location ? evaluateEnumMember(expr, member, location) : getEnumMemberValue(member.valueDeclaration);
|
|
85573
|
-
}
|
|
85574
|
-
}
|
|
85621
|
+
}
|
|
85622
|
+
if (symbol.flags & 8 /* EnumMember */) {
|
|
85623
|
+
return location ? evaluateEnumMember(expr, symbol, location) : getEnumMemberValue(symbol.valueDeclaration);
|
|
85624
|
+
}
|
|
85625
|
+
if (isConstantVariable(symbol)) {
|
|
85626
|
+
const declaration = symbol.valueDeclaration;
|
|
85627
|
+
if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) {
|
|
85628
|
+
return evaluate(declaration.initializer, declaration);
|
|
85629
|
+
}
|
|
85630
|
+
}
|
|
85631
|
+
}
|
|
85632
|
+
function evaluateElementAccessExpression(expr, location) {
|
|
85633
|
+
const root = expr.expression;
|
|
85634
|
+
if (isEntityNameExpression(root) && isStringLiteralLike(expr.argumentExpression)) {
|
|
85635
|
+
const rootSymbol = resolveEntityName(
|
|
85636
|
+
root,
|
|
85637
|
+
111551 /* Value */,
|
|
85638
|
+
/*ignoreErrors*/
|
|
85639
|
+
true
|
|
85640
|
+
);
|
|
85641
|
+
if (rootSymbol && rootSymbol.flags & 384 /* Enum */) {
|
|
85642
|
+
const name = escapeLeadingUnderscores(expr.argumentExpression.text);
|
|
85643
|
+
const member = rootSymbol.exports.get(name);
|
|
85644
|
+
if (member) {
|
|
85645
|
+
return location ? evaluateEnumMember(expr, member, location) : getEnumMemberValue(member.valueDeclaration);
|
|
85575
85646
|
}
|
|
85576
|
-
|
|
85647
|
+
}
|
|
85577
85648
|
}
|
|
85578
|
-
return void 0;
|
|
85579
85649
|
}
|
|
85580
85650
|
function evaluateEnumMember(expr, symbol, location) {
|
|
85581
85651
|
const declaration = symbol.valueDeclaration;
|
|
@@ -85589,18 +85659,6 @@ function createTypeChecker(host) {
|
|
|
85589
85659
|
}
|
|
85590
85660
|
return getEnumMemberValue(declaration);
|
|
85591
85661
|
}
|
|
85592
|
-
function evaluateTemplateExpression(expr, location) {
|
|
85593
|
-
let result = expr.head.text;
|
|
85594
|
-
for (const span of expr.templateSpans) {
|
|
85595
|
-
const value = evaluate(span.expression, location);
|
|
85596
|
-
if (value === void 0) {
|
|
85597
|
-
return void 0;
|
|
85598
|
-
}
|
|
85599
|
-
result += value;
|
|
85600
|
-
result += span.literal.text;
|
|
85601
|
-
}
|
|
85602
|
-
return result;
|
|
85603
|
-
}
|
|
85604
85662
|
function checkEnumDeclaration(node) {
|
|
85605
85663
|
addLazyDiagnostic(() => checkEnumDeclarationWorker(node));
|
|
85606
85664
|
}
|
|
@@ -87867,9 +87925,23 @@ function createTypeChecker(host) {
|
|
|
87867
87925
|
function isDeclarationWithPossibleInnerTypeNodeReuse(declaration) {
|
|
87868
87926
|
return isFunctionLike(declaration) || isExportAssignment(declaration) || isVariableLike(declaration);
|
|
87869
87927
|
}
|
|
87928
|
+
function getAllAccessorDeclarationsForDeclaration(accessor) {
|
|
87929
|
+
accessor = getParseTreeNode(accessor, isGetOrSetAccessorDeclaration);
|
|
87930
|
+
const otherKind = accessor.kind === 178 /* SetAccessor */ ? 177 /* GetAccessor */ : 178 /* SetAccessor */;
|
|
87931
|
+
const otherAccessor = getDeclarationOfKind(getSymbolOfDeclaration(accessor), otherKind);
|
|
87932
|
+
const firstAccessor = otherAccessor && otherAccessor.pos < accessor.pos ? otherAccessor : accessor;
|
|
87933
|
+
const secondAccessor = otherAccessor && otherAccessor.pos < accessor.pos ? accessor : otherAccessor;
|
|
87934
|
+
const setAccessor = accessor.kind === 178 /* SetAccessor */ ? accessor : otherAccessor;
|
|
87935
|
+
const getAccessor = accessor.kind === 177 /* GetAccessor */ ? accessor : otherAccessor;
|
|
87936
|
+
return {
|
|
87937
|
+
firstAccessor,
|
|
87938
|
+
secondAccessor,
|
|
87939
|
+
setAccessor,
|
|
87940
|
+
getAccessor
|
|
87941
|
+
};
|
|
87942
|
+
}
|
|
87870
87943
|
function getPossibleTypeNodeReuseExpression(declaration) {
|
|
87871
|
-
|
|
87872
|
-
return isFunctionLike(declaration) && !isSetAccessor(declaration) ? getSingleReturnExpression(declaration) : isExportAssignment(declaration) ? declaration.expression : !!declaration.initializer ? declaration.initializer : isParameter(declaration) && isSetAccessor(declaration.parent) ? getSingleReturnExpression(getAllAccessorDeclarations((_a = getSymbolOfDeclaration(declaration.parent)) == null ? void 0 : _a.declarations, declaration.parent).getAccessor) : void 0;
|
|
87944
|
+
return isFunctionLike(declaration) && !isSetAccessor(declaration) ? getSingleReturnExpression(declaration) : isExportAssignment(declaration) ? declaration.expression : !!declaration.initializer ? declaration.initializer : isParameter(declaration) && isSetAccessor(declaration.parent) ? getSingleReturnExpression(getAllAccessorDeclarationsForDeclaration(declaration.parent).getAccessor) : void 0;
|
|
87873
87945
|
}
|
|
87874
87946
|
function getSingleReturnExpression(declaration) {
|
|
87875
87947
|
let candidateExpr;
|
|
@@ -87895,20 +87967,7 @@ function createTypeChecker(host) {
|
|
|
87895
87967
|
if (!signatureDeclaration) {
|
|
87896
87968
|
return factory.createToken(133 /* AnyKeyword */);
|
|
87897
87969
|
}
|
|
87898
|
-
|
|
87899
|
-
const typePredicate = getTypePredicateOfSignature(signature);
|
|
87900
|
-
if (typePredicate) {
|
|
87901
|
-
return nodeBuilder.typePredicateToTypePredicateNode(typePredicate, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
|
|
87902
|
-
}
|
|
87903
|
-
return nodeBuilder.expressionOrTypeToTypeNode(
|
|
87904
|
-
getPossibleTypeNodeReuseExpression(signatureDeclaration),
|
|
87905
|
-
getReturnTypeOfSignature(signature),
|
|
87906
|
-
/*addUndefined*/
|
|
87907
|
-
void 0,
|
|
87908
|
-
enclosingDeclaration,
|
|
87909
|
-
flags | 1024 /* MultilineObjectLiterals */,
|
|
87910
|
-
tracker
|
|
87911
|
-
);
|
|
87970
|
+
return nodeBuilder.serializeReturnTypeForSignature(getSignatureFromDeclaration(signatureDeclaration), enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
|
|
87912
87971
|
}
|
|
87913
87972
|
function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) {
|
|
87914
87973
|
const expr = getParseTreeNode(exprIn, isExpression);
|
|
@@ -88067,6 +88126,35 @@ function createTypeChecker(host) {
|
|
|
88067
88126
|
return parseIsolatedEntityName(compilerOptions.jsxFragmentFactory, languageVersion);
|
|
88068
88127
|
}
|
|
88069
88128
|
}
|
|
88129
|
+
function getNonlocalEffectiveTypeAnnotationNode(node) {
|
|
88130
|
+
const direct = getEffectiveTypeAnnotationNode(node);
|
|
88131
|
+
if (direct) {
|
|
88132
|
+
return direct;
|
|
88133
|
+
}
|
|
88134
|
+
if (node.kind === 169 /* Parameter */ && node.parent.kind === 178 /* SetAccessor */) {
|
|
88135
|
+
const other = getAllAccessorDeclarationsForDeclaration(node.parent).getAccessor;
|
|
88136
|
+
if (other) {
|
|
88137
|
+
return getEffectiveReturnTypeNode(other);
|
|
88138
|
+
}
|
|
88139
|
+
}
|
|
88140
|
+
return void 0;
|
|
88141
|
+
}
|
|
88142
|
+
function getNonlocalEffectiveReturnTypeAnnotationNode(node) {
|
|
88143
|
+
const direct = getEffectiveReturnTypeNode(node);
|
|
88144
|
+
if (direct) {
|
|
88145
|
+
return direct;
|
|
88146
|
+
}
|
|
88147
|
+
if (node.kind === 177 /* GetAccessor */) {
|
|
88148
|
+
const other = getAllAccessorDeclarationsForDeclaration(node).setAccessor;
|
|
88149
|
+
if (other) {
|
|
88150
|
+
const param = getSetAccessorValueParameter(other);
|
|
88151
|
+
if (param) {
|
|
88152
|
+
return getEffectiveTypeAnnotationNode(param);
|
|
88153
|
+
}
|
|
88154
|
+
}
|
|
88155
|
+
}
|
|
88156
|
+
return void 0;
|
|
88157
|
+
}
|
|
88070
88158
|
function createResolver() {
|
|
88071
88159
|
return {
|
|
88072
88160
|
getReferencedExportContainer,
|
|
@@ -88120,34 +88208,19 @@ function createTypeChecker(host) {
|
|
|
88120
88208
|
},
|
|
88121
88209
|
getJsxFactoryEntity,
|
|
88122
88210
|
getJsxFragmentFactoryEntity,
|
|
88123
|
-
getAllAccessorDeclarations(accessor) {
|
|
88124
|
-
accessor = getParseTreeNode(accessor, isGetOrSetAccessorDeclaration);
|
|
88125
|
-
const otherKind = accessor.kind === 178 /* SetAccessor */ ? 177 /* GetAccessor */ : 178 /* SetAccessor */;
|
|
88126
|
-
const otherAccessor = getDeclarationOfKind(getSymbolOfDeclaration(accessor), otherKind);
|
|
88127
|
-
const firstAccessor = otherAccessor && otherAccessor.pos < accessor.pos ? otherAccessor : accessor;
|
|
88128
|
-
const secondAccessor = otherAccessor && otherAccessor.pos < accessor.pos ? accessor : otherAccessor;
|
|
88129
|
-
const setAccessor = accessor.kind === 178 /* SetAccessor */ ? accessor : otherAccessor;
|
|
88130
|
-
const getAccessor = accessor.kind === 177 /* GetAccessor */ ? accessor : otherAccessor;
|
|
88131
|
-
return {
|
|
88132
|
-
firstAccessor,
|
|
88133
|
-
secondAccessor,
|
|
88134
|
-
setAccessor,
|
|
88135
|
-
getAccessor
|
|
88136
|
-
};
|
|
88137
|
-
},
|
|
88138
88211
|
isBindingCapturedByNode: (node, decl) => {
|
|
88139
88212
|
const parseNode = getParseTreeNode(node);
|
|
88140
88213
|
const parseDecl = getParseTreeNode(decl);
|
|
88141
88214
|
return !!parseNode && !!parseDecl && (isVariableDeclaration(parseDecl) || isBindingElement(parseDecl)) && isBindingCapturedByNode(parseNode, parseDecl);
|
|
88142
88215
|
},
|
|
88143
|
-
getDeclarationStatementsForSourceFile: (node, flags, tracker
|
|
88216
|
+
getDeclarationStatementsForSourceFile: (node, flags, tracker) => {
|
|
88144
88217
|
const n = getParseTreeNode(node);
|
|
88145
88218
|
Debug.assert(n && n.kind === 307 /* SourceFile */, "Non-sourcefile node passed into getDeclarationsForSourceFile");
|
|
88146
88219
|
const sym = getSymbolOfDeclaration(node);
|
|
88147
88220
|
if (!sym) {
|
|
88148
|
-
return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker
|
|
88221
|
+
return !node.locals ? [] : nodeBuilder.symbolTableToDeclarationStatements(node.locals, node, flags, tracker);
|
|
88149
88222
|
}
|
|
88150
|
-
return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker
|
|
88223
|
+
return !sym.exports ? [] : nodeBuilder.symbolTableToDeclarationStatements(sym.exports, node, flags, tracker);
|
|
88151
88224
|
},
|
|
88152
88225
|
isImportRequiredByAugmentation
|
|
88153
88226
|
};
|
|
@@ -88489,7 +88562,7 @@ function createTypeChecker(host) {
|
|
|
88489
88562
|
return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_not_valid_here);
|
|
88490
88563
|
}
|
|
88491
88564
|
} else if (legacyDecorators && (node.kind === 177 /* GetAccessor */ || node.kind === 178 /* SetAccessor */)) {
|
|
88492
|
-
const accessors =
|
|
88565
|
+
const accessors = getAllAccessorDeclarationsForDeclaration(node);
|
|
88493
88566
|
if (hasDecorators(accessors.firstAccessor) && node === accessors.secondAccessor) {
|
|
88494
88567
|
return grammarErrorOnFirstToken(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name);
|
|
88495
88568
|
}
|
|
@@ -93867,7 +93940,7 @@ function transformTypeScript(context) {
|
|
|
93867
93940
|
if (typeSerializer) {
|
|
93868
93941
|
let decorators;
|
|
93869
93942
|
if (shouldAddTypeMetadata(node)) {
|
|
93870
|
-
const typeMetadata = emitHelpers().createMetadataHelper("design:type", typeSerializer.serializeTypeOfNode({ currentLexicalScope, currentNameScope: container }, node));
|
|
93943
|
+
const typeMetadata = emitHelpers().createMetadataHelper("design:type", typeSerializer.serializeTypeOfNode({ currentLexicalScope, currentNameScope: container }, node, container));
|
|
93871
93944
|
decorators = append(decorators, factory2.createDecorator(typeMetadata));
|
|
93872
93945
|
}
|
|
93873
93946
|
if (shouldAddParamTypesMetadata(node)) {
|
|
@@ -93894,7 +93967,7 @@ function transformTypeScript(context) {
|
|
|
93894
93967
|
/*type*/
|
|
93895
93968
|
void 0,
|
|
93896
93969
|
factory2.createToken(39 /* EqualsGreaterThanToken */),
|
|
93897
|
-
typeSerializer.serializeTypeOfNode({ currentLexicalScope, currentNameScope: container }, node)
|
|
93970
|
+
typeSerializer.serializeTypeOfNode({ currentLexicalScope, currentNameScope: container }, node, container)
|
|
93898
93971
|
));
|
|
93899
93972
|
properties = append(properties, typeProperty);
|
|
93900
93973
|
}
|
|
@@ -97331,7 +97404,7 @@ function createRuntimeTypeSerializer(context) {
|
|
|
97331
97404
|
let currentNameScope;
|
|
97332
97405
|
return {
|
|
97333
97406
|
serializeTypeNode: (serializerContext, node) => setSerializerContextAnd(serializerContext, serializeTypeNode, node),
|
|
97334
|
-
serializeTypeOfNode: (serializerContext, node) => setSerializerContextAnd(serializerContext, serializeTypeOfNode, node),
|
|
97407
|
+
serializeTypeOfNode: (serializerContext, node, container) => setSerializerContextAnd(serializerContext, serializeTypeOfNode, node, container),
|
|
97335
97408
|
serializeParameterTypesOfNode: (serializerContext, node, container) => setSerializerContextAnd(serializerContext, serializeParameterTypesOfNode, node, container),
|
|
97336
97409
|
serializeReturnTypeOfNode: (serializerContext, node) => setSerializerContextAnd(serializerContext, serializeReturnTypeOfNode, node)
|
|
97337
97410
|
};
|
|
@@ -97345,18 +97418,18 @@ function createRuntimeTypeSerializer(context) {
|
|
|
97345
97418
|
currentNameScope = savedCurrentNameScope;
|
|
97346
97419
|
return result;
|
|
97347
97420
|
}
|
|
97348
|
-
function getAccessorTypeNode(node) {
|
|
97349
|
-
const accessors =
|
|
97421
|
+
function getAccessorTypeNode(node, container) {
|
|
97422
|
+
const accessors = getAllAccessorDeclarations(container.members, node);
|
|
97350
97423
|
return accessors.setAccessor && getSetAccessorTypeAnnotationNode(accessors.setAccessor) || accessors.getAccessor && getEffectiveReturnTypeNode(accessors.getAccessor);
|
|
97351
97424
|
}
|
|
97352
|
-
function serializeTypeOfNode(node) {
|
|
97425
|
+
function serializeTypeOfNode(node, container) {
|
|
97353
97426
|
switch (node.kind) {
|
|
97354
97427
|
case 172 /* PropertyDeclaration */:
|
|
97355
97428
|
case 169 /* Parameter */:
|
|
97356
97429
|
return serializeTypeNode(node.type);
|
|
97357
97430
|
case 178 /* SetAccessor */:
|
|
97358
97431
|
case 177 /* GetAccessor */:
|
|
97359
|
-
return serializeTypeNode(getAccessorTypeNode(node));
|
|
97432
|
+
return serializeTypeNode(getAccessorTypeNode(node, container));
|
|
97360
97433
|
case 263 /* ClassDeclaration */:
|
|
97361
97434
|
case 231 /* ClassExpression */:
|
|
97362
97435
|
case 174 /* MethodDeclaration */:
|
|
@@ -97379,7 +97452,7 @@ function createRuntimeTypeSerializer(context) {
|
|
|
97379
97452
|
if (parameter.dotDotDotToken) {
|
|
97380
97453
|
expressions.push(serializeTypeNode(getRestParameterElementType(parameter.type)));
|
|
97381
97454
|
} else {
|
|
97382
|
-
expressions.push(serializeTypeOfNode(parameter));
|
|
97455
|
+
expressions.push(serializeTypeOfNode(parameter, container));
|
|
97383
97456
|
}
|
|
97384
97457
|
}
|
|
97385
97458
|
}
|
|
@@ -113406,13 +113479,13 @@ function transformDeclarations(context) {
|
|
|
113406
113479
|
context.addDiagnostic(createDiagnosticForNode(errorNameNode || errorFallbackNode, Diagnostics.The_type_of_this_node_cannot_be_serialized_because_its_property_0_cannot_be_serialized, propertyName));
|
|
113407
113480
|
}
|
|
113408
113481
|
}
|
|
113409
|
-
function transformDeclarationsForJS(sourceFile
|
|
113482
|
+
function transformDeclarationsForJS(sourceFile) {
|
|
113410
113483
|
const oldDiag = getSymbolAccessibilityDiagnostic;
|
|
113411
113484
|
getSymbolAccessibilityDiagnostic = (s) => s.errorNode && canProduceDiagnostics(s.errorNode) ? createGetSymbolAccessibilityDiagnosticForNode(s.errorNode)(s) : {
|
|
113412
113485
|
diagnosticMessage: s.errorModuleName ? Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit : Diagnostics.Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit,
|
|
113413
113486
|
errorNode: s.errorNode || sourceFile
|
|
113414
113487
|
};
|
|
113415
|
-
const result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker
|
|
113488
|
+
const result = resolver.getDeclarationStatementsForSourceFile(sourceFile, declarationEmitNodeBuilderFlags, symbolTracker);
|
|
113416
113489
|
getSymbolAccessibilityDiagnostic = oldDiag;
|
|
113417
113490
|
return result;
|
|
113418
113491
|
}
|
|
@@ -113443,11 +113516,7 @@ function transformDeclarations(context) {
|
|
|
113443
113516
|
if (isExternalOrCommonJsModule(sourceFile) || isJsonSourceFile(sourceFile)) {
|
|
113444
113517
|
resultHasExternalModuleIndicator = false;
|
|
113445
113518
|
needsDeclare = false;
|
|
113446
|
-
const statements = isSourceFileJS(sourceFile) ? factory2.createNodeArray(transformDeclarationsForJS(
|
|
113447
|
-
sourceFile,
|
|
113448
|
-
/*bundled*/
|
|
113449
|
-
true
|
|
113450
|
-
)) : visitNodes2(sourceFile.statements, visitDeclarationStatements, isStatement);
|
|
113519
|
+
const statements = isSourceFileJS(sourceFile) ? factory2.createNodeArray(transformDeclarationsForJS(sourceFile)) : visitNodes2(sourceFile.statements, visitDeclarationStatements, isStatement);
|
|
113451
113520
|
const newFile = factory2.updateSourceFile(
|
|
113452
113521
|
sourceFile,
|
|
113453
113522
|
[factory2.createModuleDeclaration(
|
|
@@ -113769,7 +113838,7 @@ function transformDeclarations(context) {
|
|
|
113769
113838
|
if (!isPrivate) {
|
|
113770
113839
|
const valueParameter = getSetAccessorValueParameter(input);
|
|
113771
113840
|
if (valueParameter) {
|
|
113772
|
-
const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input,
|
|
113841
|
+
const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, getAllAccessorDeclarations(isObjectLiteralExpression(input.parent) ? input.parent.properties : input.parent.members, input));
|
|
113773
113842
|
newValueParameter = ensureParameter(
|
|
113774
113843
|
valueParameter,
|
|
113775
113844
|
/*modifierMask*/
|
|
@@ -114055,7 +114124,7 @@ function transformDeclarations(context) {
|
|
|
114055
114124
|
void 0
|
|
114056
114125
|
);
|
|
114057
114126
|
}
|
|
114058
|
-
const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input,
|
|
114127
|
+
const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, getAllAccessorDeclarations(isObjectLiteralExpression(input.parent) ? input.parent.properties : input.parent.members, input));
|
|
114059
114128
|
return cleanup(factory2.updateGetAccessorDeclaration(
|
|
114060
114129
|
input,
|
|
114061
114130
|
ensureModifiers(input),
|
|
@@ -115914,7 +115983,6 @@ var notImplementedResolver = {
|
|
|
115914
115983
|
isLiteralConstDeclaration: notImplemented,
|
|
115915
115984
|
getJsxFactoryEntity: notImplemented,
|
|
115916
115985
|
getJsxFragmentFactoryEntity: notImplemented,
|
|
115917
|
-
getAllAccessorDeclarations: notImplemented,
|
|
115918
115986
|
isBindingCapturedByNode: notImplemented,
|
|
115919
115987
|
getDeclarationStatementsForSourceFile: notImplemented,
|
|
115920
115988
|
isImportRequiredByAugmentation: notImplemented
|
|
@@ -122023,6 +122091,7 @@ function createProgram(rootNamesOrOptions, _options, _host, _oldProgram, _config
|
|
|
122023
122091
|
getResolvedProjectReferenceByPath,
|
|
122024
122092
|
forEachResolvedProjectReference: forEachResolvedProjectReference2,
|
|
122025
122093
|
isSourceOfProjectReferenceRedirect,
|
|
122094
|
+
getRedirectReferenceForResolutionFromSourceOfProject,
|
|
122026
122095
|
emitBuildInfo,
|
|
122027
122096
|
fileExists,
|
|
122028
122097
|
readFile,
|
|
@@ -126939,7 +127008,8 @@ function createResolutionCache(resolutionHost, rootDirForResolution, logChangesW
|
|
|
126939
127008
|
impliedFormatPackageJsons.delete(newFile.resolvedPath);
|
|
126940
127009
|
});
|
|
126941
127010
|
impliedFormatPackageJsons.forEach((existing, path) => {
|
|
126942
|
-
|
|
127011
|
+
const newFile = newProgram == null ? void 0 : newProgram.getSourceFileByPath(path);
|
|
127012
|
+
if (!newFile || newFile.resolvedPath !== path) {
|
|
126943
127013
|
existing.forEach((location) => fileWatchesOfAffectingLocations.get(location).files--);
|
|
126944
127014
|
impliedFormatPackageJsons.delete(path);
|
|
126945
127015
|
}
|
|
@@ -159431,7 +159501,8 @@ function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, con
|
|
|
159431
159501
|
}
|
|
159432
159502
|
function symbolAppearsToBeTypeOnly(symbol) {
|
|
159433
159503
|
var _a;
|
|
159434
|
-
|
|
159504
|
+
const flags = getCombinedLocalAndExportSymbolFlags(skipAlias(symbol, typeChecker));
|
|
159505
|
+
return !(flags & 111551 /* Value */) && (!isInJSFile((_a = symbol.declarations) == null ? void 0 : _a[0]) || !!(flags & 788968 /* Type */));
|
|
159435
159506
|
}
|
|
159436
159507
|
}
|
|
159437
159508
|
function getLabelCompletionAtPosition(node) {
|
|
@@ -159736,10 +159807,7 @@ function getContextualType(previousToken, position, sourceFile, checker) {
|
|
|
159736
159807
|
return isJsxExpression(parent2) && !isJsxElement(parent2.parent) && !isJsxFragment(parent2.parent) ? checker.getContextualTypeForJsxAttribute(parent2.parent) : void 0;
|
|
159737
159808
|
default:
|
|
159738
159809
|
const argInfo = ts_SignatureHelp_exports.getArgumentInfoForCompletions(previousToken, position, sourceFile, checker);
|
|
159739
|
-
return argInfo ? (
|
|
159740
|
-
// At `,`, treat this as the next argument after the comma.
|
|
159741
|
-
checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex + (previousToken.kind === 28 /* CommaToken */ ? 1 : 0))
|
|
159742
|
-
) : isEqualityOperatorKind(previousToken.kind) && isBinaryExpression(parent2) && isEqualityOperatorKind(parent2.operatorToken.kind) ? (
|
|
159810
|
+
return argInfo ? checker.getContextualTypeForArgumentAtIndex(argInfo.invocation, argInfo.argumentIndex) : isEqualityOperatorKind(previousToken.kind) && isBinaryExpression(parent2) && isEqualityOperatorKind(parent2.operatorToken.kind) ? (
|
|
159743
159811
|
// completion at `x ===/**/` should be for the right side
|
|
159744
159812
|
checker.getTypeAtLocation(parent2.left)
|
|
159745
159813
|
) : checker.getContextualType(previousToken, 4 /* Completions */) || checker.getContextualType(previousToken);
|
|
@@ -168127,12 +168195,7 @@ function getArgumentOrParameterListInfo(node, position, sourceFile, checker) {
|
|
|
168127
168195
|
if (!info)
|
|
168128
168196
|
return void 0;
|
|
168129
168197
|
const { list, argumentIndex } = info;
|
|
168130
|
-
const argumentCount = getArgumentCount(
|
|
168131
|
-
list,
|
|
168132
|
-
/*ignoreTrailingComma*/
|
|
168133
|
-
isInString(sourceFile, position, node),
|
|
168134
|
-
checker
|
|
168135
|
-
);
|
|
168198
|
+
const argumentCount = getArgumentCount(checker, list);
|
|
168136
168199
|
if (argumentIndex !== 0) {
|
|
168137
168200
|
Debug.assertLessThan(argumentIndex, argumentCount);
|
|
168138
168201
|
}
|
|
@@ -168144,7 +168207,7 @@ function getArgumentOrParameterListAndIndex(node, sourceFile, checker) {
|
|
|
168144
168207
|
return { list: getChildListThatStartsWithOpenerToken(node.parent, node, sourceFile), argumentIndex: 0 };
|
|
168145
168208
|
} else {
|
|
168146
168209
|
const list = findContainingList(node);
|
|
168147
|
-
return list && { list, argumentIndex: getArgumentIndex(list, node
|
|
168210
|
+
return list && { list, argumentIndex: getArgumentIndex(checker, list, node) };
|
|
168148
168211
|
}
|
|
168149
168212
|
}
|
|
168150
168213
|
function getImmediatelyContainingArgumentInfo(node, position, sourceFile, checker) {
|
|
@@ -168274,24 +168337,6 @@ function chooseBetterSymbol(s) {
|
|
|
168274
168337
|
return isFunctionTypeNode(d) ? (_a = tryCast(d.parent, canHaveSymbol)) == null ? void 0 : _a.symbol : void 0;
|
|
168275
168338
|
}) || s : s;
|
|
168276
168339
|
}
|
|
168277
|
-
function getArgumentIndex(argumentsList, node, checker) {
|
|
168278
|
-
const args = argumentsList.getChildren();
|
|
168279
|
-
let argumentIndex = 0;
|
|
168280
|
-
for (let pos = 0; pos < length(args); pos++) {
|
|
168281
|
-
const child = args[pos];
|
|
168282
|
-
if (child === node) {
|
|
168283
|
-
break;
|
|
168284
|
-
}
|
|
168285
|
-
if (isSpreadElement(child)) {
|
|
168286
|
-
argumentIndex = argumentIndex + getSpreadElementCount(child, checker) + (pos > 0 ? pos : 0);
|
|
168287
|
-
} else {
|
|
168288
|
-
if (child.kind !== 28 /* CommaToken */) {
|
|
168289
|
-
argumentIndex++;
|
|
168290
|
-
}
|
|
168291
|
-
}
|
|
168292
|
-
}
|
|
168293
|
-
return argumentIndex;
|
|
168294
|
-
}
|
|
168295
168340
|
function getSpreadElementCount(node, checker) {
|
|
168296
168341
|
const spreadType = checker.getTypeAtLocation(node.expression);
|
|
168297
168342
|
if (checker.isTupleType(spreadType)) {
|
|
@@ -168304,19 +168349,48 @@ function getSpreadElementCount(node, checker) {
|
|
|
168304
168349
|
}
|
|
168305
168350
|
return 0;
|
|
168306
168351
|
}
|
|
168307
|
-
function
|
|
168308
|
-
|
|
168309
|
-
|
|
168310
|
-
|
|
168352
|
+
function getArgumentIndex(checker, argumentsList, node) {
|
|
168353
|
+
return getArgumentIndexOrCount(checker, argumentsList, node);
|
|
168354
|
+
}
|
|
168355
|
+
function getArgumentCount(checker, argumentsList) {
|
|
168356
|
+
return getArgumentIndexOrCount(
|
|
168357
|
+
checker,
|
|
168358
|
+
argumentsList,
|
|
168359
|
+
/*node*/
|
|
168360
|
+
void 0
|
|
168361
|
+
);
|
|
168362
|
+
}
|
|
168363
|
+
function getArgumentIndexOrCount(checker, argumentsList, node) {
|
|
168364
|
+
const args = argumentsList.getChildren();
|
|
168365
|
+
let argumentIndex = 0;
|
|
168366
|
+
let skipComma = false;
|
|
168367
|
+
for (const child of args) {
|
|
168368
|
+
if (node && child === node) {
|
|
168369
|
+
if (!skipComma && child.kind === 28 /* CommaToken */) {
|
|
168370
|
+
argumentIndex++;
|
|
168371
|
+
}
|
|
168372
|
+
return argumentIndex;
|
|
168373
|
+
}
|
|
168311
168374
|
if (isSpreadElement(child)) {
|
|
168312
|
-
|
|
168375
|
+
argumentIndex += getSpreadElementCount(child, checker);
|
|
168376
|
+
skipComma = true;
|
|
168377
|
+
continue;
|
|
168378
|
+
}
|
|
168379
|
+
if (child.kind !== 28 /* CommaToken */) {
|
|
168380
|
+
argumentIndex++;
|
|
168381
|
+
skipComma = true;
|
|
168382
|
+
continue;
|
|
168383
|
+
}
|
|
168384
|
+
if (skipComma) {
|
|
168385
|
+
skipComma = false;
|
|
168386
|
+
continue;
|
|
168313
168387
|
}
|
|
168388
|
+
argumentIndex++;
|
|
168314
168389
|
}
|
|
168315
|
-
|
|
168316
|
-
|
|
168317
|
-
argumentCount++;
|
|
168390
|
+
if (node) {
|
|
168391
|
+
return argumentIndex;
|
|
168318
168392
|
}
|
|
168319
|
-
return
|
|
168393
|
+
return args.length && last(args).kind === 28 /* CommaToken */ ? argumentIndex + 1 : argumentIndex;
|
|
168320
168394
|
}
|
|
168321
168395
|
function getArgumentIndexForTemplatePiece(spanIndex, node, position, sourceFile) {
|
|
168322
168396
|
Debug.assert(position >= node.getStart(), "Assumed 'position' could not occur before node.");
|
|
@@ -173851,6 +173925,7 @@ __export(ts_exports2, {
|
|
|
173851
173925
|
createEmitAndSemanticDiagnosticsBuilderProgram: () => createEmitAndSemanticDiagnosticsBuilderProgram,
|
|
173852
173926
|
createEmitHelperFactory: () => createEmitHelperFactory,
|
|
173853
173927
|
createEmptyExports: () => createEmptyExports,
|
|
173928
|
+
createEvaluator: () => createEvaluator,
|
|
173854
173929
|
createExpressionForJsxElement: () => createExpressionForJsxElement,
|
|
173855
173930
|
createExpressionForJsxFragment: () => createExpressionForJsxFragment,
|
|
173856
173931
|
createExpressionForObjectLiteralElementLike: () => createExpressionForObjectLiteralElementLike,
|
|
@@ -180069,7 +180144,16 @@ function createWatchFactoryHostUsingWatchEvents(service, canUseWatchEvents) {
|
|
|
180069
180144
|
recursive ? watchedDirectoriesRecursive : watchedDirectories,
|
|
180070
180145
|
path,
|
|
180071
180146
|
callback,
|
|
180072
|
-
(id) => ({
|
|
180147
|
+
(id) => ({
|
|
180148
|
+
eventName: CreateDirectoryWatcherEvent,
|
|
180149
|
+
data: {
|
|
180150
|
+
id,
|
|
180151
|
+
path,
|
|
180152
|
+
recursive: !!recursive,
|
|
180153
|
+
// Special case node_modules as we watch it for changes to closed script infos as well
|
|
180154
|
+
ignoreUpdate: !path.endsWith("/node_modules") ? true : void 0
|
|
180155
|
+
}
|
|
180156
|
+
})
|
|
180073
180157
|
);
|
|
180074
180158
|
}
|
|
180075
180159
|
function getOrCreateFileWatcher({ pathToId, idToCallbacks }, path, callback, event) {
|
|
@@ -180096,24 +180180,28 @@ function createWatchFactoryHostUsingWatchEvents(service, canUseWatchEvents) {
|
|
|
180096
180180
|
}
|
|
180097
180181
|
};
|
|
180098
180182
|
}
|
|
180099
|
-
function onWatchChange(
|
|
180100
|
-
|
|
180101
|
-
|
|
180102
|
-
|
|
180183
|
+
function onWatchChange(args) {
|
|
180184
|
+
if (isArray(args))
|
|
180185
|
+
args.forEach(onWatchChangeRequestArgs);
|
|
180186
|
+
else
|
|
180187
|
+
onWatchChangeRequestArgs(args);
|
|
180103
180188
|
}
|
|
180104
|
-
function
|
|
180105
|
-
|
|
180106
|
-
(
|
|
180107
|
-
|
|
180108
|
-
callback(eventPath, eventKind);
|
|
180109
|
-
});
|
|
180189
|
+
function onWatchChangeRequestArgs({ id, created, deleted, updated }) {
|
|
180190
|
+
onWatchEventType(id, created, 0 /* Created */);
|
|
180191
|
+
onWatchEventType(id, deleted, 2 /* Deleted */);
|
|
180192
|
+
onWatchEventType(id, updated, 1 /* Changed */);
|
|
180110
180193
|
}
|
|
180111
|
-
function
|
|
180112
|
-
|
|
180113
|
-
if (eventType === "update")
|
|
180194
|
+
function onWatchEventType(id, paths, eventKind) {
|
|
180195
|
+
if (!(paths == null ? void 0 : paths.length))
|
|
180114
180196
|
return;
|
|
180115
|
-
(
|
|
180116
|
-
|
|
180197
|
+
forEachCallback(watchedFiles, id, paths, (callback, eventPath) => callback(eventPath, eventKind));
|
|
180198
|
+
forEachCallback(watchedDirectories, id, paths, (callback, eventPath) => callback(eventPath));
|
|
180199
|
+
forEachCallback(watchedDirectoriesRecursive, id, paths, (callback, eventPath) => callback(eventPath));
|
|
180200
|
+
}
|
|
180201
|
+
function forEachCallback(hostWatcherMap, id, eventPaths, cb) {
|
|
180202
|
+
var _a;
|
|
180203
|
+
(_a = hostWatcherMap.idToCallbacks.get(id)) == null ? void 0 : _a.forEach((callback) => {
|
|
180204
|
+
eventPaths.forEach((eventPath) => cb(callback, normalizeSlashes(eventPath)));
|
|
180117
180205
|
});
|
|
180118
180206
|
}
|
|
180119
180207
|
}
|
|
@@ -183086,7 +183174,6 @@ Dynamic files must always be opened with service's current directory or service
|
|
|
183086
183174
|
(fileName, eventKind) => {
|
|
183087
183175
|
switch (eventKind) {
|
|
183088
183176
|
case 0 /* Created */:
|
|
183089
|
-
return Debug.fail();
|
|
183090
183177
|
case 1 /* Changed */:
|
|
183091
183178
|
this.packageJsonCache.addOrUpdate(fileName, path);
|
|
183092
183179
|
this.onPackageJsonChange(result);
|
|
@@ -188054,6 +188141,7 @@ if (typeof console !== "undefined") {
|
|
|
188054
188141
|
createEmitAndSemanticDiagnosticsBuilderProgram,
|
|
188055
188142
|
createEmitHelperFactory,
|
|
188056
188143
|
createEmptyExports,
|
|
188144
|
+
createEvaluator,
|
|
188057
188145
|
createExpressionForJsxElement,
|
|
188058
188146
|
createExpressionForJsxFragment,
|
|
188059
188147
|
createExpressionForObjectLiteralElementLike,
|