@typescript-deploys/pr-build 5.5.0-pr-57465-98 → 5.5.0-pr-57772-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/tsc.js +246 -112
- package/lib/tsserver.js +350 -193
- package/lib/typescript.js +350 -193
- package/lib/typingsInstaller.js +5 -1
- package/package.json +2 -2
package/lib/tsc.js
CHANGED
|
@@ -18,7 +18,7 @@ and limitations under the License.
|
|
|
18
18
|
|
|
19
19
|
// src/compiler/corePublic.ts
|
|
20
20
|
var versionMajorMinor = "5.5";
|
|
21
|
-
var version = `${versionMajorMinor}.0-insiders.
|
|
21
|
+
var version = `${versionMajorMinor}.0-insiders.20240314`;
|
|
22
22
|
|
|
23
23
|
// src/compiler/core.ts
|
|
24
24
|
var emptyArray = [];
|
|
@@ -6096,6 +6096,8 @@ var Diagnostics = {
|
|
|
6096
6096
|
The_left_hand_side_of_a_for_in_statement_cannot_be_an_await_using_declaration: diag(1494, 1 /* Error */, "The_left_hand_side_of_a_for_in_statement_cannot_be_an_await_using_declaration_1494", "The left-hand side of a 'for...in' statement cannot be an 'await using' declaration."),
|
|
6097
6097
|
_0_modifier_cannot_appear_on_an_await_using_declaration: diag(1495, 1 /* Error */, "_0_modifier_cannot_appear_on_an_await_using_declaration_1495", "'{0}' modifier cannot appear on an 'await using' declaration."),
|
|
6098
6098
|
Identifier_string_literal_or_number_literal_expected: diag(1496, 1 /* Error */, "Identifier_string_literal_or_number_literal_expected_1496", "Identifier, string literal, or number literal expected."),
|
|
6099
|
+
Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator: diag(1497, 1 /* Error */, "Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator_1497", "Expression must be enclosed in parentheses to be used as a decorator."),
|
|
6100
|
+
Invalid_syntax_in_decorator: diag(1498, 1 /* Error */, "Invalid_syntax_in_decorator_1498", "Invalid syntax in decorator."),
|
|
6099
6101
|
The_types_of_0_are_incompatible_between_these_types: diag(2200, 1 /* Error */, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
|
|
6100
6102
|
The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, 1 /* Error */, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
|
|
6101
6103
|
Call_signature_return_types_0_and_1_are_incompatible: diag(
|
|
@@ -7747,6 +7749,8 @@ var Diagnostics = {
|
|
|
7747
7749
|
Add_optional_parameter_to_0: diag(95191, 3 /* Message */, "Add_optional_parameter_to_0_95191", "Add optional parameter to '{0}'"),
|
|
7748
7750
|
Add_optional_parameters_to_0: diag(95192, 3 /* Message */, "Add_optional_parameters_to_0_95192", "Add optional parameters to '{0}'"),
|
|
7749
7751
|
Add_all_optional_parameters: diag(95193, 3 /* Message */, "Add_all_optional_parameters_95193", "Add all optional parameters"),
|
|
7752
|
+
Wrap_in_parentheses: diag(95194, 3 /* Message */, "Wrap_in_parentheses_95194", "Wrap in parentheses"),
|
|
7753
|
+
Wrap_all_invalid_decorator_expressions_in_parentheses: diag(95195, 3 /* Message */, "Wrap_all_invalid_decorator_expressions_in_parentheses_95195", "Wrap all invalid decorator expressions in parentheses"),
|
|
7750
7754
|
No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, 1 /* Error */, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
|
|
7751
7755
|
Classes_may_not_have_a_field_named_constructor: diag(18006, 1 /* Error */, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
|
|
7752
7756
|
JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, 1 /* Error */, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
|
|
@@ -17650,6 +17654,20 @@ function replaceFirstStar(s, replacement) {
|
|
|
17650
17654
|
function getNameFromImportAttribute(node) {
|
|
17651
17655
|
return isIdentifier(node.name) ? node.name.escapedText : escapeLeadingUnderscores(node.name.text);
|
|
17652
17656
|
}
|
|
17657
|
+
function isSyntacticallyString(expr) {
|
|
17658
|
+
expr = skipOuterExpressions(expr);
|
|
17659
|
+
switch (expr.kind) {
|
|
17660
|
+
case 226 /* BinaryExpression */:
|
|
17661
|
+
const left = expr.left;
|
|
17662
|
+
const right = expr.right;
|
|
17663
|
+
return expr.operatorToken.kind === 40 /* PlusToken */ && (isSyntacticallyString(left) || isSyntacticallyString(right));
|
|
17664
|
+
case 228 /* TemplateExpression */:
|
|
17665
|
+
case 11 /* StringLiteral */:
|
|
17666
|
+
case 15 /* NoSubstitutionTemplateLiteral */:
|
|
17667
|
+
return true;
|
|
17668
|
+
}
|
|
17669
|
+
return false;
|
|
17670
|
+
}
|
|
17653
17671
|
|
|
17654
17672
|
// src/compiler/factory/baseNodeFactory.ts
|
|
17655
17673
|
function createBaseNodeFactory() {
|
|
@@ -39795,7 +39813,7 @@ function createBinder() {
|
|
|
39795
39813
|
inAssignmentPattern = saveInAssignmentPattern;
|
|
39796
39814
|
return;
|
|
39797
39815
|
}
|
|
39798
|
-
if (node.kind >= 243 /* FirstStatement */ && node.kind <= 259 /* LastStatement */ &&
|
|
39816
|
+
if (node.kind >= 243 /* FirstStatement */ && node.kind <= 259 /* LastStatement */ && !options.allowUnreachableCode) {
|
|
39799
39817
|
node.flowNode = currentFlow;
|
|
39800
39818
|
}
|
|
39801
39819
|
switch (node.kind) {
|
|
@@ -47769,6 +47787,18 @@ function createTypeChecker(host) {
|
|
|
47769
47787
|
function createNodeBuilder() {
|
|
47770
47788
|
return {
|
|
47771
47789
|
typeToTypeNode: (type, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => typeToTypeNodeHelper(type, context)),
|
|
47790
|
+
expressionOrTypeToTypeNode: (type, expr, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => expressionOrTypeToTypeNode(context, expr, type, addUndefined)),
|
|
47791
|
+
serializeTypeForDeclaration: (type, symbol, addUndefined, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => serializeTypeForDeclaration(
|
|
47792
|
+
context,
|
|
47793
|
+
type,
|
|
47794
|
+
symbol,
|
|
47795
|
+
enclosingDeclaration,
|
|
47796
|
+
/*includePrivateSymbol*/
|
|
47797
|
+
void 0,
|
|
47798
|
+
/*bundled*/
|
|
47799
|
+
void 0,
|
|
47800
|
+
addUndefined
|
|
47801
|
+
)),
|
|
47772
47802
|
indexInfoToIndexSignatureDeclaration: (indexInfo, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => indexInfoToIndexSignatureDeclarationHelper(
|
|
47773
47803
|
indexInfo,
|
|
47774
47804
|
context,
|
|
@@ -47790,6 +47820,47 @@ function createTypeChecker(host) {
|
|
|
47790
47820
|
symbolTableToDeclarationStatements: (symbolTable, enclosingDeclaration, flags, tracker, bundled) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolTableToDeclarationStatements(symbolTable, context, bundled)),
|
|
47791
47821
|
symbolToNode: (symbol, meaning, enclosingDeclaration, flags, tracker) => withContext(enclosingDeclaration, flags, tracker, (context) => symbolToNode(symbol, context, meaning))
|
|
47792
47822
|
};
|
|
47823
|
+
function expressionOrTypeToTypeNode(context, expr, type, addUndefined) {
|
|
47824
|
+
if (expr) {
|
|
47825
|
+
const typeNode = isAssertionExpression(expr) ? expr.type : isJSDocTypeAssertion(expr) ? getJSDocTypeAssertionType(expr) : void 0;
|
|
47826
|
+
if (typeNode && !isConstTypeReference(typeNode)) {
|
|
47827
|
+
const result = tryReuseExistingTypeNode(context, typeNode, type, expr.parent, addUndefined);
|
|
47828
|
+
if (result) {
|
|
47829
|
+
return result;
|
|
47830
|
+
}
|
|
47831
|
+
}
|
|
47832
|
+
}
|
|
47833
|
+
if (addUndefined) {
|
|
47834
|
+
type = getOptionalType(type);
|
|
47835
|
+
}
|
|
47836
|
+
return typeToTypeNodeHelper(type, context);
|
|
47837
|
+
}
|
|
47838
|
+
function tryReuseExistingTypeNode(context, typeNode, type, host2, addUndefined, includePrivateSymbol, bundled) {
|
|
47839
|
+
const originalType = type;
|
|
47840
|
+
if (addUndefined) {
|
|
47841
|
+
type = getOptionalType(type);
|
|
47842
|
+
}
|
|
47843
|
+
const clone = tryReuseExistingNonParameterTypeNode(context, typeNode, type, host2, includePrivateSymbol, bundled);
|
|
47844
|
+
if (clone) {
|
|
47845
|
+
return clone;
|
|
47846
|
+
}
|
|
47847
|
+
if (addUndefined && originalType !== type) {
|
|
47848
|
+
const cloneMissingUndefined = tryReuseExistingNonParameterTypeNode(context, typeNode, originalType, host2, includePrivateSymbol, bundled);
|
|
47849
|
+
if (cloneMissingUndefined) {
|
|
47850
|
+
return factory.createUnionTypeNode([cloneMissingUndefined, factory.createKeywordTypeNode(157 /* UndefinedKeyword */)]);
|
|
47851
|
+
}
|
|
47852
|
+
}
|
|
47853
|
+
return void 0;
|
|
47854
|
+
}
|
|
47855
|
+
function tryReuseExistingNonParameterTypeNode(context, existing, type, host2 = context.enclosingDeclaration, includePrivateSymbol, bundled, annotationType) {
|
|
47856
|
+
if (typeNodeIsEquivalentToType(existing, host2, type, annotationType) && existingTypeNodeIsNotReferenceOrIsReferenceWithCompatibleTypeArgumentCount(existing, type)) {
|
|
47857
|
+
const result = serializeExistingTypeNode(context, existing, includePrivateSymbol, bundled);
|
|
47858
|
+
if (result) {
|
|
47859
|
+
return result;
|
|
47860
|
+
}
|
|
47861
|
+
}
|
|
47862
|
+
return void 0;
|
|
47863
|
+
}
|
|
47793
47864
|
function symbolToNode(symbol, context, meaning) {
|
|
47794
47865
|
if (context.flags & 1073741824 /* WriteComputedProps */) {
|
|
47795
47866
|
if (symbol.valueDeclaration) {
|
|
@@ -48231,8 +48302,8 @@ function createTypeChecker(host) {
|
|
|
48231
48302
|
if (isInstantiationExpressionType) {
|
|
48232
48303
|
const instantiationExpressionType = type2;
|
|
48233
48304
|
const existing = instantiationExpressionType.node;
|
|
48234
|
-
if (isTypeQueryNode(existing)
|
|
48235
|
-
const typeNode =
|
|
48305
|
+
if (isTypeQueryNode(existing)) {
|
|
48306
|
+
const typeNode = tryReuseExistingNonParameterTypeNode(context, existing, type2);
|
|
48236
48307
|
if (typeNode) {
|
|
48237
48308
|
return typeNode;
|
|
48238
48309
|
}
|
|
@@ -49035,11 +49106,9 @@ function createTypeChecker(host) {
|
|
|
49035
49106
|
}
|
|
49036
49107
|
function symbolToParameterDeclaration(parameterSymbol, context, preserveModifierFlags, privateSymbolVisitor, bundledImports) {
|
|
49037
49108
|
const parameterDeclaration = getEffectiveParameterDeclaration(parameterSymbol);
|
|
49038
|
-
|
|
49039
|
-
|
|
49040
|
-
|
|
49041
|
-
}
|
|
49042
|
-
const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports);
|
|
49109
|
+
const parameterType = getTypeOfSymbol(parameterSymbol);
|
|
49110
|
+
const addUndefined = parameterDeclaration && isRequiredInitializedParameter(parameterDeclaration);
|
|
49111
|
+
const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports, addUndefined);
|
|
49043
49112
|
const modifiers = !(context.flags & 8192 /* OmitParameterModifiers */) && preserveModifierFlags && parameterDeclaration && canHaveModifiers(parameterDeclaration) ? map(getModifiers(parameterDeclaration), factory.cloneNode) : void 0;
|
|
49044
49113
|
const isRest = parameterDeclaration && isRestParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & 32768 /* RestParameter */;
|
|
49045
49114
|
const dotDotDotToken = isRest ? factory.createToken(26 /* DotDotDotToken */) : void 0;
|
|
@@ -49629,16 +49698,15 @@ function createTypeChecker(host) {
|
|
|
49629
49698
|
}
|
|
49630
49699
|
return enclosingDeclaration;
|
|
49631
49700
|
}
|
|
49632
|
-
function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled) {
|
|
49701
|
+
function serializeTypeForDeclaration(context, type, symbol, enclosingDeclaration, includePrivateSymbol, bundled, addUndefined) {
|
|
49702
|
+
var _a;
|
|
49633
49703
|
if (!isErrorType(type) && enclosingDeclaration) {
|
|
49634
49704
|
const declWithExistingAnnotation = getDeclarationWithTypeAnnotation(symbol, getEnclosingDeclarationIgnoringFakeScope(enclosingDeclaration));
|
|
49635
49705
|
if (declWithExistingAnnotation && !isFunctionLikeDeclaration(declWithExistingAnnotation) && !isGetAccessorDeclaration(declWithExistingAnnotation)) {
|
|
49636
49706
|
const existing = getEffectiveTypeAnnotationNode(declWithExistingAnnotation);
|
|
49637
|
-
|
|
49638
|
-
|
|
49639
|
-
|
|
49640
|
-
return result2;
|
|
49641
|
-
}
|
|
49707
|
+
const result2 = tryReuseExistingTypeNode(context, existing, type, declWithExistingAnnotation, addUndefined, includePrivateSymbol, bundled);
|
|
49708
|
+
if (result2) {
|
|
49709
|
+
return result2;
|
|
49642
49710
|
}
|
|
49643
49711
|
}
|
|
49644
49712
|
}
|
|
@@ -49646,16 +49714,17 @@ function createTypeChecker(host) {
|
|
|
49646
49714
|
if (type.flags & 8192 /* UniqueESSymbol */ && type.symbol === symbol && (!context.enclosingDeclaration || some(symbol.declarations, (d) => getSourceFileOfNode(d) === getSourceFileOfNode(context.enclosingDeclaration)))) {
|
|
49647
49715
|
context.flags |= 1048576 /* AllowUniqueESSymbolType */;
|
|
49648
49716
|
}
|
|
49649
|
-
const
|
|
49717
|
+
const decl = symbol.valueDeclaration || ((_a = symbol.declarations) == null ? void 0 : _a[0]);
|
|
49718
|
+
const expr = decl && isDeclarationWithPossibleInnerTypeNodeReuse(decl) ? getPossibleTypeNodeReuseExpression(decl) : void 0;
|
|
49719
|
+
const result = expressionOrTypeToTypeNode(context, expr, type, addUndefined);
|
|
49650
49720
|
context.flags = oldFlags;
|
|
49651
49721
|
return result;
|
|
49652
49722
|
}
|
|
49653
|
-
function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type) {
|
|
49654
|
-
const typeFromTypeNode = getTypeFromTypeNode(typeNode);
|
|
49723
|
+
function typeNodeIsEquivalentToType(typeNode, annotatedDeclaration, type, typeFromTypeNode = getTypeFromTypeNode(typeNode)) {
|
|
49655
49724
|
if (typeFromTypeNode === type) {
|
|
49656
49725
|
return true;
|
|
49657
49726
|
}
|
|
49658
|
-
if (isParameter(annotatedDeclaration) && annotatedDeclaration.questionToken) {
|
|
49727
|
+
if (annotatedDeclaration && (isParameter(annotatedDeclaration) || isPropertyDeclaration(annotatedDeclaration)) && annotatedDeclaration.questionToken) {
|
|
49659
49728
|
return getTypeWithFacts(type, 524288 /* NEUndefined */) === typeFromTypeNode;
|
|
49660
49729
|
}
|
|
49661
49730
|
return false;
|
|
@@ -49667,11 +49736,9 @@ function createTypeChecker(host) {
|
|
|
49667
49736
|
if (!!findAncestor(annotation, (n) => n === enclosingDeclarationIgnoringFakeScope) && annotation) {
|
|
49668
49737
|
const annotated = getTypeFromTypeNode(annotation);
|
|
49669
49738
|
const thisInstantiated = annotated.flags & 262144 /* TypeParameter */ && annotated.isThisType ? instantiateType(annotated, signature.mapper) : annotated;
|
|
49670
|
-
|
|
49671
|
-
|
|
49672
|
-
|
|
49673
|
-
return result;
|
|
49674
|
-
}
|
|
49739
|
+
const result = tryReuseExistingNonParameterTypeNode(context, annotation, type, signature.declaration, includePrivateSymbol, bundled, thisInstantiated);
|
|
49740
|
+
if (result) {
|
|
49741
|
+
return result;
|
|
49675
49742
|
}
|
|
49676
49743
|
}
|
|
49677
49744
|
}
|
|
@@ -49700,7 +49767,9 @@ function createTypeChecker(host) {
|
|
|
49700
49767
|
/*shouldComputeAliasesToMakeVisible*/
|
|
49701
49768
|
false
|
|
49702
49769
|
).accessibility !== 0 /* Accessible */) {
|
|
49703
|
-
|
|
49770
|
+
if (!isDeclarationName(node)) {
|
|
49771
|
+
introducesError = true;
|
|
49772
|
+
}
|
|
49704
49773
|
} else {
|
|
49705
49774
|
context.tracker.trackSymbol(sym, context.enclosingDeclaration, -1 /* All */);
|
|
49706
49775
|
includePrivateSymbol == null ? void 0 : includePrivateSymbol(sym);
|
|
@@ -49838,6 +49907,31 @@ function createTypeChecker(host) {
|
|
|
49838
49907
|
node.isTypeOf
|
|
49839
49908
|
);
|
|
49840
49909
|
}
|
|
49910
|
+
if (isParameter(node)) {
|
|
49911
|
+
if (!node.type && !node.initializer) {
|
|
49912
|
+
return factory.updateParameterDeclaration(
|
|
49913
|
+
node,
|
|
49914
|
+
/*modifiers*/
|
|
49915
|
+
void 0,
|
|
49916
|
+
node.dotDotDotToken,
|
|
49917
|
+
visitEachChild(
|
|
49918
|
+
node.name,
|
|
49919
|
+
visitExistingNodeTreeSymbols,
|
|
49920
|
+
/*context*/
|
|
49921
|
+
void 0
|
|
49922
|
+
),
|
|
49923
|
+
node.questionToken,
|
|
49924
|
+
factory.createKeywordTypeNode(133 /* AnyKeyword */),
|
|
49925
|
+
/*initializer*/
|
|
49926
|
+
void 0
|
|
49927
|
+
);
|
|
49928
|
+
}
|
|
49929
|
+
}
|
|
49930
|
+
if (isPropertySignature(node)) {
|
|
49931
|
+
if (!node.type && !node.initializer) {
|
|
49932
|
+
return factory.updatePropertySignature(node, node.modifiers, node.name, node.questionToken, factory.createKeywordTypeNode(133 /* AnyKeyword */));
|
|
49933
|
+
}
|
|
49934
|
+
}
|
|
49841
49935
|
if (isEntityName(node) || isEntityNameExpression(node)) {
|
|
49842
49936
|
const { introducesError, node: result } = trackExistingEntityName(node, context, includePrivateSymbol);
|
|
49843
49937
|
hadError = hadError || introducesError;
|
|
@@ -49845,7 +49939,7 @@ function createTypeChecker(host) {
|
|
|
49845
49939
|
return result;
|
|
49846
49940
|
}
|
|
49847
49941
|
}
|
|
49848
|
-
if (file && isTupleTypeNode(node) && getLineAndCharacterOfPosition(file, node.pos).line === getLineAndCharacterOfPosition(file, node.end).line) {
|
|
49942
|
+
if (file && isTupleTypeNode(node) && !nodeIsSynthesized(node) && getLineAndCharacterOfPosition(file, node.pos).line === getLineAndCharacterOfPosition(file, node.end).line) {
|
|
49849
49943
|
setEmitFlags(node, 1 /* SingleLine */);
|
|
49850
49944
|
}
|
|
49851
49945
|
return visitEachChild(
|
|
@@ -50369,7 +50463,15 @@ function createTypeChecker(host) {
|
|
|
50369
50463
|
context.flags |= 8388608 /* InTypeAlias */;
|
|
50370
50464
|
const oldEnclosingDecl = context.enclosingDeclaration;
|
|
50371
50465
|
context.enclosingDeclaration = jsdocAliasDecl;
|
|
50372
|
-
const typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && isJSDocTypeExpression(jsdocAliasDecl.typeExpression) &&
|
|
50466
|
+
const typeNode = jsdocAliasDecl && jsdocAliasDecl.typeExpression && isJSDocTypeExpression(jsdocAliasDecl.typeExpression) && tryReuseExistingNonParameterTypeNode(
|
|
50467
|
+
context,
|
|
50468
|
+
jsdocAliasDecl.typeExpression.type,
|
|
50469
|
+
aliasType,
|
|
50470
|
+
/*host*/
|
|
50471
|
+
void 0,
|
|
50472
|
+
includePrivateSymbol,
|
|
50473
|
+
bundled
|
|
50474
|
+
) || typeToTypeNodeHelper(aliasType, context);
|
|
50373
50475
|
addResult(
|
|
50374
50476
|
setSyntheticLeadingComments(
|
|
50375
50477
|
factory.createTypeAliasDeclaration(
|
|
@@ -50602,7 +50704,15 @@ function createTypeChecker(host) {
|
|
|
50602
50704
|
}
|
|
50603
50705
|
return cleanup(factory.createExpressionWithTypeArguments(
|
|
50604
50706
|
expr,
|
|
50605
|
-
map(e.typeArguments, (a) =>
|
|
50707
|
+
map(e.typeArguments, (a) => tryReuseExistingNonParameterTypeNode(
|
|
50708
|
+
context,
|
|
50709
|
+
a,
|
|
50710
|
+
getTypeFromTypeNode(a),
|
|
50711
|
+
/*host*/
|
|
50712
|
+
void 0,
|
|
50713
|
+
includePrivateSymbol,
|
|
50714
|
+
bundled
|
|
50715
|
+
) || typeToTypeNodeHelper(getTypeFromTypeNode(a), context))
|
|
50606
50716
|
));
|
|
50607
50717
|
function cleanup(result2) {
|
|
50608
50718
|
context.enclosingDeclaration = oldEnclosing;
|
|
@@ -51061,8 +51171,10 @@ function createTypeChecker(host) {
|
|
|
51061
51171
|
}
|
|
51062
51172
|
}
|
|
51063
51173
|
function isTypeRepresentableAsFunctionNamespaceMerge(typeToSerialize, hostSymbol) {
|
|
51174
|
+
var _a2;
|
|
51064
51175
|
const ctxSrc = getSourceFileOfNode(context.enclosingDeclaration);
|
|
51065
|
-
return getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && !
|
|
51176
|
+
return getObjectFlags(typeToSerialize) & (16 /* Anonymous */ | 32 /* Mapped */) && !some((_a2 = typeToSerialize.symbol) == null ? void 0 : _a2.declarations, isTypeNode) && // If the type comes straight from a type node, we shouldn't try to break it up
|
|
51177
|
+
!length(getIndexInfosOfType(typeToSerialize)) && !isClassInstanceSide(typeToSerialize) && // While a class instance is potentially representable as a NS, prefer printing a reference to the instance type and serializing the class
|
|
51066
51178
|
!!(length(filter(getPropertiesOfType(typeToSerialize), isNamespaceMember)) || length(getSignaturesOfType(typeToSerialize, 0 /* Call */))) && !length(getSignaturesOfType(typeToSerialize, 1 /* Construct */)) && // TODO: could probably serialize as function + ns + class, now that that's OK
|
|
51067
51179
|
!getDeclarationWithTypeAnnotation(hostSymbol, enclosingDeclaration) && !(typeToSerialize.symbol && some(typeToSerialize.symbol.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && !some(getPropertiesOfType(typeToSerialize), (p) => isLateBoundName(p.escapedName)) && !some(getPropertiesOfType(typeToSerialize), (p) => some(p.declarations, (d) => getSourceFileOfNode(d) !== ctxSrc)) && every(getPropertiesOfType(typeToSerialize), (p) => {
|
|
51068
51180
|
if (!isIdentifierText(symbolName(p), languageVersion)) {
|
|
@@ -55641,15 +55753,7 @@ function createTypeChecker(host) {
|
|
|
55641
55753
|
jsdocPredicate = getTypePredicateOfSignature(jsdocSignature);
|
|
55642
55754
|
}
|
|
55643
55755
|
}
|
|
55644
|
-
|
|
55645
|
-
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
55646
|
-
} else if (signature.declaration && isFunctionLikeDeclaration(signature.declaration) && (!signature.resolvedReturnType || signature.resolvedReturnType.flags & 16 /* Boolean */)) {
|
|
55647
|
-
const { declaration } = signature;
|
|
55648
|
-
signature.resolvedTypePredicate = noTypePredicate;
|
|
55649
|
-
signature.resolvedTypePredicate = getTypePredicateFromBody(declaration) || noTypePredicate;
|
|
55650
|
-
} else {
|
|
55651
|
-
signature.resolvedTypePredicate = noTypePredicate;
|
|
55652
|
-
}
|
|
55756
|
+
signature.resolvedTypePredicate = type && isTypePredicateNode(type) ? createTypePredicateFromTypePredicateNode(type, signature) : jsdocPredicate || noTypePredicate;
|
|
55653
55757
|
}
|
|
55654
55758
|
Debug.assert(!!signature.resolvedTypePredicate);
|
|
55655
55759
|
}
|
|
@@ -57599,7 +57703,7 @@ function createTypeChecker(host) {
|
|
|
57599
57703
|
const typeVarIndex = typeSet[0].flags & 8650752 /* TypeVariable */ ? 0 : 1;
|
|
57600
57704
|
const typeVariable = typeSet[typeVarIndex];
|
|
57601
57705
|
const primitiveType = typeSet[1 - typeVarIndex];
|
|
57602
|
-
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
57706
|
+
if (typeVariable.flags & 8650752 /* TypeVariable */ && (primitiveType.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */) && !isGenericStringLikeType(primitiveType) || includes & 16777216 /* IncludesEmptyObject */)) {
|
|
57603
57707
|
const constraint = getBaseConstraintOfType(typeVariable);
|
|
57604
57708
|
if (constraint && everyType(constraint, (t) => !!(t.flags & (402784252 /* Primitive */ | 67108864 /* NonPrimitive */)) || isEmptyAnonymousObjectType(t))) {
|
|
57605
57709
|
if (isTypeStrictSubtypeOf(constraint, primitiveType)) {
|
|
@@ -58204,6 +58308,9 @@ function createTypeChecker(host) {
|
|
|
58204
58308
|
function isPatternLiteralType(type) {
|
|
58205
58309
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && every(type.types, isPatternLiteralPlaceholderType) || !!(type.flags & 268435456 /* StringMapping */) && isPatternLiteralPlaceholderType(type.type);
|
|
58206
58310
|
}
|
|
58311
|
+
function isGenericStringLikeType(type) {
|
|
58312
|
+
return !!(type.flags & (134217728 /* TemplateLiteral */ | 268435456 /* StringMapping */)) && !isPatternLiteralType(type);
|
|
58313
|
+
}
|
|
58207
58314
|
function isGenericType(type) {
|
|
58208
58315
|
return !!getGenericObjectFlags(type);
|
|
58209
58316
|
}
|
|
@@ -58226,7 +58333,7 @@ function createTypeChecker(host) {
|
|
|
58226
58333
|
}
|
|
58227
58334
|
return type.objectFlags & 12582912 /* IsGenericType */;
|
|
58228
58335
|
}
|
|
58229
|
-
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */
|
|
58336
|
+
return (type.flags & 58982400 /* InstantiableNonPrimitive */ || isGenericMappedType(type) || isGenericTupleType(type) ? 4194304 /* IsGenericObjectType */ : 0) | (type.flags & (58982400 /* InstantiableNonPrimitive */ | 4194304 /* Index */) || isGenericStringLikeType(type) ? 8388608 /* IsGenericIndexType */ : 0);
|
|
58230
58337
|
}
|
|
58231
58338
|
function getSimplifiedType(type, writing) {
|
|
58232
58339
|
return type.flags & 8388608 /* IndexedAccess */ ? getSimplifiedIndexedAccessType(type, writing) : type.flags & 16777216 /* Conditional */ ? getSimplifiedConditionalType(type, writing) : type;
|
|
@@ -71493,7 +71600,10 @@ function createTypeChecker(host) {
|
|
|
71493
71600
|
return Debug.fail();
|
|
71494
71601
|
}
|
|
71495
71602
|
function getDecoratorArgumentCount(node, signature) {
|
|
71496
|
-
return compilerOptions.experimentalDecorators ? getLegacyDecoratorArgumentCount(node, signature) :
|
|
71603
|
+
return compilerOptions.experimentalDecorators ? getLegacyDecoratorArgumentCount(node, signature) : (
|
|
71604
|
+
// Allow the runtime to oversupply arguments to an ES decorator as long as there's at least one parameter.
|
|
71605
|
+
Math.min(Math.max(getParameterCount(signature), 1), 2)
|
|
71606
|
+
);
|
|
71497
71607
|
}
|
|
71498
71608
|
function getLegacyDecoratorArgumentCount(node, signature) {
|
|
71499
71609
|
switch (node.parent.kind) {
|
|
@@ -74073,67 +74183,6 @@ function createTypeChecker(host) {
|
|
|
74073
74183
|
return false;
|
|
74074
74184
|
}
|
|
74075
74185
|
}
|
|
74076
|
-
function getTypePredicateFromBody(func) {
|
|
74077
|
-
switch (func.kind) {
|
|
74078
|
-
case 176 /* Constructor */:
|
|
74079
|
-
case 177 /* GetAccessor */:
|
|
74080
|
-
case 178 /* SetAccessor */:
|
|
74081
|
-
return void 0;
|
|
74082
|
-
}
|
|
74083
|
-
const functionFlags = getFunctionFlags(func);
|
|
74084
|
-
if (functionFlags !== 0 /* Normal */ || func.parameters.length === 0)
|
|
74085
|
-
return void 0;
|
|
74086
|
-
let singleReturn;
|
|
74087
|
-
if (func.body && func.body.kind !== 241 /* Block */) {
|
|
74088
|
-
singleReturn = func.body;
|
|
74089
|
-
} else {
|
|
74090
|
-
const bailedEarly = forEachReturnStatement(func.body, (returnStatement) => {
|
|
74091
|
-
if (singleReturn || !returnStatement.expression)
|
|
74092
|
-
return true;
|
|
74093
|
-
singleReturn = returnStatement.expression;
|
|
74094
|
-
});
|
|
74095
|
-
if (bailedEarly || !singleReturn || functionHasImplicitReturn(func))
|
|
74096
|
-
return void 0;
|
|
74097
|
-
}
|
|
74098
|
-
return checkIfExpressionRefinesAnyParameter(func, singleReturn);
|
|
74099
|
-
}
|
|
74100
|
-
function checkIfExpressionRefinesAnyParameter(func, expr) {
|
|
74101
|
-
expr = skipParentheses(
|
|
74102
|
-
expr,
|
|
74103
|
-
/*excludeJSDocTypeAssertions*/
|
|
74104
|
-
true
|
|
74105
|
-
);
|
|
74106
|
-
const returnType = checkExpressionCached(expr);
|
|
74107
|
-
if (!(returnType.flags & 16 /* Boolean */))
|
|
74108
|
-
return void 0;
|
|
74109
|
-
return forEach(func.parameters, (param, i) => {
|
|
74110
|
-
const initType = getTypeOfSymbol(param.symbol);
|
|
74111
|
-
if (!initType || initType.flags & 16 /* Boolean */ || !isIdentifier(param.name) || isSymbolAssigned(param.symbol)) {
|
|
74112
|
-
return;
|
|
74113
|
-
}
|
|
74114
|
-
const trueType2 = checkIfExpressionRefinesParameter(func, expr, param, initType);
|
|
74115
|
-
if (trueType2) {
|
|
74116
|
-
return createTypePredicate(1 /* Identifier */, unescapeLeadingUnderscores(param.name.escapedText), i, trueType2);
|
|
74117
|
-
}
|
|
74118
|
-
});
|
|
74119
|
-
}
|
|
74120
|
-
function checkIfExpressionRefinesParameter(func, expr, param, initType) {
|
|
74121
|
-
const antecedent = expr.flowNode || expr.parent.kind === 253 /* ReturnStatement */ && expr.parent.flowNode || { flags: 2 /* Start */ };
|
|
74122
|
-
const trueCondition = {
|
|
74123
|
-
flags: 32 /* TrueCondition */,
|
|
74124
|
-
node: expr,
|
|
74125
|
-
antecedent
|
|
74126
|
-
};
|
|
74127
|
-
const trueType2 = getFlowTypeOfReference(param.name, initType, initType, func, trueCondition);
|
|
74128
|
-
if (trueType2 === initType)
|
|
74129
|
-
return void 0;
|
|
74130
|
-
const falseCondition = {
|
|
74131
|
-
...trueCondition,
|
|
74132
|
-
flags: 64 /* FalseCondition */
|
|
74133
|
-
};
|
|
74134
|
-
const falseSubtype = getFlowTypeOfReference(param.name, trueType2, trueType2, func, falseCondition);
|
|
74135
|
-
return falseSubtype.flags & 131072 /* Never */ ? trueType2 : void 0;
|
|
74136
|
-
}
|
|
74137
74186
|
function checkAllCodePathsInNonVoidFunctionReturnOrThrow(func, returnType) {
|
|
74138
74187
|
addLazyDiagnostic(checkAllCodePathsInNonVoidFunctionReturnOrThrowDiagnostics);
|
|
74139
74188
|
return;
|
|
@@ -77414,7 +77463,56 @@ function createTypeChecker(host) {
|
|
|
77414
77463
|
}
|
|
77415
77464
|
}
|
|
77416
77465
|
}
|
|
77466
|
+
function checkGrammarDecorator(decorator) {
|
|
77467
|
+
const sourceFile = getSourceFileOfNode(decorator);
|
|
77468
|
+
if (!hasParseDiagnostics(sourceFile)) {
|
|
77469
|
+
let node = decorator.expression;
|
|
77470
|
+
if (isParenthesizedExpression(node)) {
|
|
77471
|
+
return false;
|
|
77472
|
+
}
|
|
77473
|
+
let canHaveCallExpression = true;
|
|
77474
|
+
let errorNode;
|
|
77475
|
+
while (true) {
|
|
77476
|
+
if (isExpressionWithTypeArguments(node) || isNonNullExpression(node)) {
|
|
77477
|
+
node = node.expression;
|
|
77478
|
+
continue;
|
|
77479
|
+
}
|
|
77480
|
+
if (isCallExpression(node)) {
|
|
77481
|
+
if (!canHaveCallExpression) {
|
|
77482
|
+
errorNode = node;
|
|
77483
|
+
}
|
|
77484
|
+
if (node.questionDotToken) {
|
|
77485
|
+
errorNode = node.questionDotToken;
|
|
77486
|
+
}
|
|
77487
|
+
node = node.expression;
|
|
77488
|
+
canHaveCallExpression = false;
|
|
77489
|
+
continue;
|
|
77490
|
+
}
|
|
77491
|
+
if (isPropertyAccessExpression(node)) {
|
|
77492
|
+
if (node.questionDotToken) {
|
|
77493
|
+
errorNode = node.questionDotToken;
|
|
77494
|
+
}
|
|
77495
|
+
node = node.expression;
|
|
77496
|
+
canHaveCallExpression = false;
|
|
77497
|
+
continue;
|
|
77498
|
+
}
|
|
77499
|
+
if (!isIdentifier(node)) {
|
|
77500
|
+
errorNode = node;
|
|
77501
|
+
}
|
|
77502
|
+
break;
|
|
77503
|
+
}
|
|
77504
|
+
if (errorNode) {
|
|
77505
|
+
addRelatedInfo(
|
|
77506
|
+
error(decorator.expression, Diagnostics.Expression_must_be_enclosed_in_parentheses_to_be_used_as_a_decorator),
|
|
77507
|
+
createDiagnosticForNode(errorNode, Diagnostics.Invalid_syntax_in_decorator)
|
|
77508
|
+
);
|
|
77509
|
+
return true;
|
|
77510
|
+
}
|
|
77511
|
+
}
|
|
77512
|
+
return false;
|
|
77513
|
+
}
|
|
77417
77514
|
function checkDecorator(node) {
|
|
77515
|
+
checkGrammarDecorator(node);
|
|
77418
77516
|
const signature = getResolvedSignature(node);
|
|
77419
77517
|
checkDeprecatedSignature(signature, node);
|
|
77420
77518
|
const returnType = getReturnTypeOfSignature(signature);
|
|
@@ -82837,14 +82935,34 @@ function createTypeChecker(host) {
|
|
|
82837
82935
|
return factory.createToken(133 /* AnyKeyword */);
|
|
82838
82936
|
}
|
|
82839
82937
|
const symbol = getSymbolOfDeclaration(declaration);
|
|
82840
|
-
|
|
82841
|
-
|
|
82842
|
-
|
|
82843
|
-
|
|
82844
|
-
|
|
82845
|
-
|
|
82938
|
+
const type = symbol && !(symbol.flags & (2048 /* TypeLiteral */ | 131072 /* Signature */)) ? getWidenedLiteralType(getTypeOfSymbol(symbol)) : errorType;
|
|
82939
|
+
return nodeBuilder.serializeTypeForDeclaration(type, symbol, addUndefined, enclosingDeclaration, flags | 1024 /* MultilineObjectLiterals */, tracker);
|
|
82940
|
+
}
|
|
82941
|
+
function isDeclarationWithPossibleInnerTypeNodeReuse(declaration) {
|
|
82942
|
+
return isFunctionLike(declaration) || isExportAssignment(declaration) || isVariableLike(declaration);
|
|
82943
|
+
}
|
|
82944
|
+
function getPossibleTypeNodeReuseExpression(declaration) {
|
|
82945
|
+
var _a;
|
|
82946
|
+
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;
|
|
82947
|
+
}
|
|
82948
|
+
function getSingleReturnExpression(declaration) {
|
|
82949
|
+
let candidateExpr;
|
|
82950
|
+
if (declaration && !nodeIsMissing(declaration.body)) {
|
|
82951
|
+
const body = declaration.body;
|
|
82952
|
+
if (body && isBlock(body)) {
|
|
82953
|
+
forEachReturnStatement(body, (s) => {
|
|
82954
|
+
if (!candidateExpr) {
|
|
82955
|
+
candidateExpr = s.expression;
|
|
82956
|
+
} else {
|
|
82957
|
+
candidateExpr = void 0;
|
|
82958
|
+
return true;
|
|
82959
|
+
}
|
|
82960
|
+
});
|
|
82961
|
+
} else {
|
|
82962
|
+
candidateExpr = body;
|
|
82963
|
+
}
|
|
82846
82964
|
}
|
|
82847
|
-
return
|
|
82965
|
+
return candidateExpr;
|
|
82848
82966
|
}
|
|
82849
82967
|
function createReturnTypeOfSignatureDeclaration(signatureDeclarationIn, enclosingDeclaration, flags, tracker) {
|
|
82850
82968
|
const signatureDeclaration = getParseTreeNode(signatureDeclarationIn, isFunctionLike);
|
|
@@ -82852,7 +82970,15 @@ function createTypeChecker(host) {
|
|
|
82852
82970
|
return factory.createToken(133 /* AnyKeyword */);
|
|
82853
82971
|
}
|
|
82854
82972
|
const signature = getSignatureFromDeclaration(signatureDeclaration);
|
|
82855
|
-
return nodeBuilder.
|
|
82973
|
+
return nodeBuilder.expressionOrTypeToTypeNode(
|
|
82974
|
+
getReturnTypeOfSignature(signature),
|
|
82975
|
+
getPossibleTypeNodeReuseExpression(signatureDeclaration),
|
|
82976
|
+
/*addUndefined*/
|
|
82977
|
+
void 0,
|
|
82978
|
+
enclosingDeclaration,
|
|
82979
|
+
flags | 1024 /* MultilineObjectLiterals */,
|
|
82980
|
+
tracker
|
|
82981
|
+
);
|
|
82856
82982
|
}
|
|
82857
82983
|
function createTypeOfExpression(exprIn, enclosingDeclaration, flags, tracker) {
|
|
82858
82984
|
const expr = getParseTreeNode(exprIn, isExpression);
|
|
@@ -82860,7 +82986,15 @@ function createTypeChecker(host) {
|
|
|
82860
82986
|
return factory.createToken(133 /* AnyKeyword */);
|
|
82861
82987
|
}
|
|
82862
82988
|
const type = getWidenedType(getRegularTypeOfExpression(expr));
|
|
82863
|
-
return nodeBuilder.
|
|
82989
|
+
return nodeBuilder.expressionOrTypeToTypeNode(
|
|
82990
|
+
type,
|
|
82991
|
+
expr,
|
|
82992
|
+
/*addUndefined*/
|
|
82993
|
+
void 0,
|
|
82994
|
+
enclosingDeclaration,
|
|
82995
|
+
flags | 1024 /* MultilineObjectLiterals */,
|
|
82996
|
+
tracker
|
|
82997
|
+
);
|
|
82864
82998
|
}
|
|
82865
82999
|
function hasGlobalName(name) {
|
|
82866
83000
|
return globals.has(escapeLeadingUnderscores(name));
|
|
@@ -89403,7 +89537,7 @@ function transformTypeScript(context) {
|
|
|
89403
89537
|
),
|
|
89404
89538
|
valueExpression
|
|
89405
89539
|
);
|
|
89406
|
-
const outerAssignment = valueExpression
|
|
89540
|
+
const outerAssignment = isSyntacticallyString(valueExpression) ? innerAssignment : factory2.createAssignment(
|
|
89407
89541
|
factory2.createElementAccessExpression(
|
|
89408
89542
|
currentNamespaceContainerName,
|
|
89409
89543
|
innerAssignment
|