typescript 4.6.0-dev.20220112 → 4.6.0-dev.20220116
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 +187 -77
- package/lib/tsserver.js +264 -110
- package/lib/tsserverlibrary.js +264 -110
- package/lib/typescript.js +264 -110
- package/lib/typescriptServices.js +264 -110
- package/lib/typingsInstaller.js +234 -96
- package/package.json +1 -1
package/lib/tsserver.js
CHANGED
|
@@ -100,7 +100,7 @@ var ts;
|
|
|
100
100
|
// The following is baselined as a literal template type without intervention
|
|
101
101
|
/** The version of the TypeScript compiler release */
|
|
102
102
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
103
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220116";
|
|
104
104
|
/* @internal */
|
|
105
105
|
var Comparison;
|
|
106
106
|
(function (Comparison) {
|
|
@@ -8288,7 +8288,7 @@ var ts;
|
|
|
8288
8288
|
Parameter_0_cannot_reference_identifier_1_declared_after_it: diag(2373, ts.DiagnosticCategory.Error, "Parameter_0_cannot_reference_identifier_1_declared_after_it_2373", "Parameter '{0}' cannot reference identifier '{1}' declared after it."),
|
|
8289
8289
|
Duplicate_index_signature_for_type_0: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_index_signature_for_type_0_2374", "Duplicate index signature for type '{0}'."),
|
|
8290
8290
|
Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2375, ts.DiagnosticCategory.Error, "Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefi_2375", "Type '{0}' is not assignable to type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."),
|
|
8291
|
-
|
|
8291
|
+
A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2376, ts.DiagnosticCategory.Error, "A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_2376", "A 'super' call must be the first statement in the constructor to refer to 'super' or 'this' when a derived class contains initialized properties, parameter properties, or private identifiers."),
|
|
8292
8292
|
Constructors_for_derived_classes_must_contain_a_super_call: diag(2377, ts.DiagnosticCategory.Error, "Constructors_for_derived_classes_must_contain_a_super_call_2377", "Constructors for derived classes must contain a 'super' call."),
|
|
8293
8293
|
A_get_accessor_must_return_a_value: diag(2378, ts.DiagnosticCategory.Error, "A_get_accessor_must_return_a_value_2378", "A 'get' accessor must return a value."),
|
|
8294
8294
|
Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties: diag(2379, ts.DiagnosticCategory.Error, "Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_tr_2379", "Argument of type '{0}' is not assignable to parameter of type '{1}' with 'exactOptionalPropertyTypes: true'. Consider adding 'undefined' to the types of the target's properties."),
|
|
@@ -8311,6 +8311,7 @@ var ts;
|
|
|
8311
8311
|
constructor_cannot_be_used_as_a_parameter_property_name: diag(2398, ts.DiagnosticCategory.Error, "constructor_cannot_be_used_as_a_parameter_property_name_2398", "'constructor' cannot be used as a parameter property name."),
|
|
8312
8312
|
Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference: diag(2399, ts.DiagnosticCategory.Error, "Duplicate_identifier_this_Compiler_uses_variable_declaration_this_to_capture_this_reference_2399", "Duplicate identifier '_this'. Compiler uses variable declaration '_this' to capture 'this' reference."),
|
|
8313
8313
|
Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference: diag(2400, ts.DiagnosticCategory.Error, "Expression_resolves_to_variable_declaration_this_that_compiler_uses_to_capture_this_reference_2400", "Expression resolves to variable declaration '_this' that compiler uses to capture 'this' reference."),
|
|
8314
|
+
A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers: diag(2401, ts.DiagnosticCategory.Error, "A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_in_2401", "A 'super' call must be a root-level statement within a constructor of a derived class that contains initialized properties, parameter properties, or private identifiers."),
|
|
8314
8315
|
Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference: diag(2402, ts.DiagnosticCategory.Error, "Expression_resolves_to_super_that_compiler_uses_to_capture_base_class_reference_2402", "Expression resolves to '_super' that compiler uses to capture base class reference."),
|
|
8315
8316
|
Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_type_2: diag(2403, ts.DiagnosticCategory.Error, "Subsequent_variable_declarations_must_have_the_same_type_Variable_0_must_be_of_type_1_but_here_has_t_2403", "Subsequent variable declarations must have the same type. Variable '{0}' must be of type '{1}', but here has type '{2}'."),
|
|
8316
8317
|
The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation: diag(2404, ts.DiagnosticCategory.Error, "The_left_hand_side_of_a_for_in_statement_cannot_use_a_type_annotation_2404", "The left-hand side of a 'for...in' statement cannot use a type annotation."),
|
|
@@ -15471,6 +15472,34 @@ var ts;
|
|
|
15471
15472
|
}
|
|
15472
15473
|
}
|
|
15473
15474
|
ts.getThisContainer = getThisContainer;
|
|
15475
|
+
/**
|
|
15476
|
+
* @returns Whether the node creates a new 'this' scope for its children.
|
|
15477
|
+
*/
|
|
15478
|
+
function isThisContainerOrFunctionBlock(node) {
|
|
15479
|
+
switch (node.kind) {
|
|
15480
|
+
// Arrow functions use the same scope, but may do so in a "delayed" manner
|
|
15481
|
+
// For example, `const getThis = () => this` may be before a super() call in a derived constructor
|
|
15482
|
+
case 213 /* ArrowFunction */:
|
|
15483
|
+
case 255 /* FunctionDeclaration */:
|
|
15484
|
+
case 212 /* FunctionExpression */:
|
|
15485
|
+
case 166 /* PropertyDeclaration */:
|
|
15486
|
+
return true;
|
|
15487
|
+
case 234 /* Block */:
|
|
15488
|
+
switch (node.parent.kind) {
|
|
15489
|
+
case 170 /* Constructor */:
|
|
15490
|
+
case 168 /* MethodDeclaration */:
|
|
15491
|
+
case 171 /* GetAccessor */:
|
|
15492
|
+
case 172 /* SetAccessor */:
|
|
15493
|
+
// Object properties can have computed names; only method-like bodies start a new scope
|
|
15494
|
+
return true;
|
|
15495
|
+
default:
|
|
15496
|
+
return false;
|
|
15497
|
+
}
|
|
15498
|
+
default:
|
|
15499
|
+
return false;
|
|
15500
|
+
}
|
|
15501
|
+
}
|
|
15502
|
+
ts.isThisContainerOrFunctionBlock = isThisContainerOrFunctionBlock;
|
|
15474
15503
|
function isInTopLevelContext(node) {
|
|
15475
15504
|
// The name of a class or function declaration is a BindingIdentifier in its surrounding scope.
|
|
15476
15505
|
if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
|
|
@@ -26057,7 +26086,7 @@ var ts;
|
|
|
26057
26086
|
* @param visitor Optional callback used to visit any custom prologue directives.
|
|
26058
26087
|
*/
|
|
26059
26088
|
function copyPrologue(source, target, ensureUseStrict, visitor) {
|
|
26060
|
-
var offset = copyStandardPrologue(source, target, ensureUseStrict);
|
|
26089
|
+
var offset = copyStandardPrologue(source, target, 0, ensureUseStrict);
|
|
26061
26090
|
return copyCustomPrologue(source, target, offset, visitor);
|
|
26062
26091
|
}
|
|
26063
26092
|
function isUseStrictPrologue(node) {
|
|
@@ -26070,12 +26099,14 @@ var ts;
|
|
|
26070
26099
|
* Copies only the standard (string-expression) prologue-directives into the target statement-array.
|
|
26071
26100
|
* @param source origin statements array
|
|
26072
26101
|
* @param target result statements array
|
|
26102
|
+
* @param statementOffset The offset at which to begin the copy.
|
|
26073
26103
|
* @param ensureUseStrict boolean determining whether the function need to add prologue-directives
|
|
26104
|
+
* @returns Count of how many directive statements were copied.
|
|
26074
26105
|
*/
|
|
26075
|
-
function copyStandardPrologue(source, target, ensureUseStrict) {
|
|
26106
|
+
function copyStandardPrologue(source, target, statementOffset, ensureUseStrict) {
|
|
26107
|
+
if (statementOffset === void 0) { statementOffset = 0; }
|
|
26076
26108
|
ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
|
|
26077
26109
|
var foundUseStrict = false;
|
|
26078
|
-
var statementOffset = 0;
|
|
26079
26110
|
var numStatements = source.length;
|
|
26080
26111
|
while (statementOffset < numStatements) {
|
|
26081
26112
|
var statement = source[statementOffset];
|
|
@@ -27498,7 +27529,7 @@ var ts;
|
|
|
27498
27529
|
importName: "__createBinding",
|
|
27499
27530
|
scoped: false,
|
|
27500
27531
|
priority: 1,
|
|
27501
|
-
text: "\n var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.
|
|
27532
|
+
text: "\n var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n var desc = Object.getOwnPropertyDescriptor(m, k);\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n desc = { enumerable: true, get: function() { return m[k]; } };\n }\n Object.defineProperty(o, k2, desc);\n }) : (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n o[k2] = m[k];\n }));"
|
|
27502
27533
|
};
|
|
27503
27534
|
ts.setModuleDefaultHelper = {
|
|
27504
27535
|
name: "typescript:commonjscreatevalue",
|
|
@@ -41133,7 +41164,7 @@ var ts;
|
|
|
41133
41164
|
? 1 /* Recursive */ : 0 /* None */
|
|
41134
41165
|
};
|
|
41135
41166
|
}
|
|
41136
|
-
if (ts.isImplicitGlob(spec)) {
|
|
41167
|
+
if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
|
|
41137
41168
|
return {
|
|
41138
41169
|
key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
|
|
41139
41170
|
flags: 1 /* Recursive */
|
|
@@ -78518,32 +78549,38 @@ var ts;
|
|
|
78518
78549
|
if (classExtendsNull) {
|
|
78519
78550
|
error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
|
|
78520
78551
|
}
|
|
78521
|
-
//
|
|
78522
|
-
// if both of the following are true:
|
|
78552
|
+
// A super call must be root-level in a constructor if both of the following are true:
|
|
78523
78553
|
// - The containing class is a derived class.
|
|
78524
78554
|
// - The constructor declares parameter properties
|
|
78525
78555
|
// or the containing class declares instance member variables with initializers.
|
|
78526
|
-
var
|
|
78556
|
+
var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
|
|
78527
78557
|
(ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
|
|
78528
78558
|
ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
|
|
78529
|
-
|
|
78530
|
-
|
|
78531
|
-
|
|
78532
|
-
|
|
78533
|
-
|
|
78534
|
-
|
|
78535
|
-
|
|
78536
|
-
|
|
78537
|
-
|
|
78538
|
-
|
|
78559
|
+
if (superCallShouldBeRootLevel) {
|
|
78560
|
+
// Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
|
|
78561
|
+
// See GH #8277
|
|
78562
|
+
if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
|
|
78563
|
+
error(superCall, ts.Diagnostics.A_super_call_must_be_a_root_level_statement_within_a_constructor_of_a_derived_class_that_contains_initialized_properties_parameter_properties_or_private_identifiers);
|
|
78564
|
+
}
|
|
78565
|
+
// Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
|
|
78566
|
+
else {
|
|
78567
|
+
var superCallStatement = void 0;
|
|
78568
|
+
for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
|
|
78569
|
+
var statement = _a[_i];
|
|
78570
|
+
if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
|
|
78571
|
+
superCallStatement = statement;
|
|
78572
|
+
break;
|
|
78573
|
+
}
|
|
78574
|
+
if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
|
|
78575
|
+
break;
|
|
78576
|
+
}
|
|
78539
78577
|
}
|
|
78540
|
-
|
|
78541
|
-
|
|
78578
|
+
// Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
|
|
78579
|
+
// See GH #8277
|
|
78580
|
+
if (superCallStatement === undefined) {
|
|
78581
|
+
error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_to_refer_to_super_or_this_when_a_derived_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
|
|
78542
78582
|
}
|
|
78543
78583
|
}
|
|
78544
|
-
if (!superCallStatement) {
|
|
78545
|
-
error(node, ts.Diagnostics.A_super_call_must_be_the_first_statement_in_the_constructor_when_a_class_contains_initialized_properties_parameter_properties_or_private_identifiers);
|
|
78546
|
-
}
|
|
78547
78584
|
}
|
|
78548
78585
|
}
|
|
78549
78586
|
else if (!classExtendsNull) {
|
|
@@ -78551,6 +78588,19 @@ var ts;
|
|
|
78551
78588
|
}
|
|
78552
78589
|
}
|
|
78553
78590
|
}
|
|
78591
|
+
function superCallIsRootLevelInConstructor(superCall, body) {
|
|
78592
|
+
var superCallParent = ts.walkUpParenthesizedExpressions(superCall.parent);
|
|
78593
|
+
return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body;
|
|
78594
|
+
}
|
|
78595
|
+
function nodeImmediatelyReferencesSuperOrThis(node) {
|
|
78596
|
+
if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) {
|
|
78597
|
+
return true;
|
|
78598
|
+
}
|
|
78599
|
+
if (ts.isThisContainerOrFunctionBlock(node)) {
|
|
78600
|
+
return false;
|
|
78601
|
+
}
|
|
78602
|
+
return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
|
|
78603
|
+
}
|
|
78554
78604
|
function checkAccessorDeclaration(node) {
|
|
78555
78605
|
if (produceDiagnostics) {
|
|
78556
78606
|
// Grammar checking accessors
|
|
@@ -88673,34 +88723,31 @@ var ts;
|
|
|
88673
88723
|
}
|
|
88674
88724
|
ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
|
|
88675
88725
|
/**
|
|
88676
|
-
*
|
|
88677
|
-
|
|
88678
|
-
|
|
88679
|
-
|
|
88680
|
-
|
|
88681
|
-
|
|
88726
|
+
* @returns Contained super() call from descending into the statement ignoring parentheses, if that call exists.
|
|
88727
|
+
*/
|
|
88728
|
+
function getSuperCallFromStatement(statement) {
|
|
88729
|
+
if (!ts.isExpressionStatement(statement)) {
|
|
88730
|
+
return undefined;
|
|
88731
|
+
}
|
|
88732
|
+
var expression = ts.skipParentheses(statement.expression);
|
|
88733
|
+
return ts.isSuperCall(expression)
|
|
88734
|
+
? expression
|
|
88735
|
+
: undefined;
|
|
88736
|
+
}
|
|
88737
|
+
ts.getSuperCallFromStatement = getSuperCallFromStatement;
|
|
88738
|
+
/**
|
|
88739
|
+
* @returns The index (after prologue statements) of a super call, or -1 if not found.
|
|
88682
88740
|
*/
|
|
88683
|
-
function
|
|
88684
|
-
|
|
88685
|
-
var
|
|
88686
|
-
|
|
88687
|
-
|
|
88688
|
-
if (index === statements.length) {
|
|
88689
|
-
// list contains nothing but prologue directives (or empty) - exit
|
|
88690
|
-
return index;
|
|
88691
|
-
}
|
|
88692
|
-
var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
|
|
88693
|
-
if (superIndex > -1) {
|
|
88694
|
-
for (var i = index; i <= superIndex; i++) {
|
|
88695
|
-
result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
|
|
88696
|
-
}
|
|
88697
|
-
return superIndex + 1;
|
|
88741
|
+
function findSuperStatementIndex(statements, indexAfterLastPrologueStatement) {
|
|
88742
|
+
for (var i = indexAfterLastPrologueStatement; i < statements.length; i += 1) {
|
|
88743
|
+
var statement = statements[i];
|
|
88744
|
+
if (getSuperCallFromStatement(statement)) {
|
|
88745
|
+
return i;
|
|
88698
88746
|
}
|
|
88699
|
-
return index;
|
|
88700
88747
|
}
|
|
88701
|
-
return
|
|
88748
|
+
return -1;
|
|
88702
88749
|
}
|
|
88703
|
-
ts.
|
|
88750
|
+
ts.findSuperStatementIndex = findSuperStatementIndex;
|
|
88704
88751
|
function getProperties(node, requireInitializer, isStatic) {
|
|
88705
88752
|
return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
|
|
88706
88753
|
}
|
|
@@ -90599,6 +90646,7 @@ var ts;
|
|
|
90599
90646
|
case 176 /* TypePredicate */:
|
|
90600
90647
|
case 133 /* BooleanKeyword */:
|
|
90601
90648
|
return factory.createIdentifier("Boolean");
|
|
90649
|
+
case 197 /* TemplateLiteralType */:
|
|
90602
90650
|
case 149 /* StringKeyword */:
|
|
90603
90651
|
return factory.createIdentifier("String");
|
|
90604
90652
|
case 147 /* ObjectKeyword */:
|
|
@@ -90937,10 +90985,14 @@ var ts;
|
|
|
90937
90985
|
return ts.visitFunctionBody(body, visitor, context);
|
|
90938
90986
|
}
|
|
90939
90987
|
var statements = [];
|
|
90940
|
-
var indexOfFirstStatement = 0;
|
|
90941
90988
|
resumeLexicalEnvironment();
|
|
90942
|
-
|
|
90943
|
-
|
|
90989
|
+
var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
|
|
90990
|
+
var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
|
|
90991
|
+
// If there was a super call, visit existing statements up to and including it
|
|
90992
|
+
if (superStatementIndex >= 0) {
|
|
90993
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement));
|
|
90994
|
+
}
|
|
90995
|
+
// Transform parameters into property assignments. Transforms this:
|
|
90944
90996
|
//
|
|
90945
90997
|
// constructor (public x, public y) {
|
|
90946
90998
|
// }
|
|
@@ -90952,9 +91004,17 @@ var ts;
|
|
|
90952
91004
|
// this.y = y;
|
|
90953
91005
|
// }
|
|
90954
91006
|
//
|
|
90955
|
-
|
|
90956
|
-
//
|
|
90957
|
-
|
|
91007
|
+
var parameterPropertyAssignments = ts.mapDefined(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment);
|
|
91008
|
+
// If there is a super() call, the parameter properties go immediately after it
|
|
91009
|
+
if (superStatementIndex >= 0) {
|
|
91010
|
+
ts.addRange(statements, parameterPropertyAssignments);
|
|
91011
|
+
}
|
|
91012
|
+
// Since there was no super() call, parameter properties are the first statements in the constructor
|
|
91013
|
+
else {
|
|
91014
|
+
statements = ts.addRange(parameterPropertyAssignments, statements);
|
|
91015
|
+
}
|
|
91016
|
+
// Add remaining statements from the body, skipping the super() call if it was found
|
|
91017
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
|
|
90958
91018
|
// End the lexical environment.
|
|
90959
91019
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
90960
91020
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -92852,6 +92912,7 @@ var ts;
|
|
|
92852
92912
|
/*modifiers*/ undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
|
|
92853
92913
|
}
|
|
92854
92914
|
function transformConstructorBody(node, constructor, isDerivedClass) {
|
|
92915
|
+
var _a;
|
|
92855
92916
|
var properties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false);
|
|
92856
92917
|
if (!useDefineForClassFields) {
|
|
92857
92918
|
properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
|
|
@@ -92863,9 +92924,21 @@ var ts;
|
|
|
92863
92924
|
return ts.visitFunctionBody(/*node*/ undefined, visitor, context);
|
|
92864
92925
|
}
|
|
92865
92926
|
resumeLexicalEnvironment();
|
|
92866
|
-
var
|
|
92927
|
+
var needsSyntheticConstructor = !constructor && isDerivedClass;
|
|
92928
|
+
var indexOfFirstStatementAfterSuper = 0;
|
|
92929
|
+
var prologueStatementCount = 0;
|
|
92930
|
+
var superStatementIndex = -1;
|
|
92867
92931
|
var statements = [];
|
|
92868
|
-
if (
|
|
92932
|
+
if ((_a = constructor === null || constructor === void 0 ? void 0 : constructor.body) === null || _a === void 0 ? void 0 : _a.statements) {
|
|
92933
|
+
prologueStatementCount = factory.copyPrologue(constructor.body.statements, statements, /*ensureUseStrict*/ false, visitor);
|
|
92934
|
+
superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
|
|
92935
|
+
// If there was a super call, visit existing statements up to and including it
|
|
92936
|
+
if (superStatementIndex >= 0) {
|
|
92937
|
+
indexOfFirstStatementAfterSuper = superStatementIndex + 1;
|
|
92938
|
+
statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
|
|
92939
|
+
}
|
|
92940
|
+
}
|
|
92941
|
+
if (needsSyntheticConstructor) {
|
|
92869
92942
|
// Add a synthetic `super` call:
|
|
92870
92943
|
//
|
|
92871
92944
|
// super(...arguments);
|
|
@@ -92873,9 +92946,6 @@ var ts;
|
|
|
92873
92946
|
statements.push(factory.createExpressionStatement(factory.createCallExpression(factory.createSuper(),
|
|
92874
92947
|
/*typeArguments*/ undefined, [factory.createSpreadElement(factory.createIdentifier("arguments"))])));
|
|
92875
92948
|
}
|
|
92876
|
-
if (constructor) {
|
|
92877
|
-
indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
|
|
92878
|
-
}
|
|
92879
92949
|
// Add the property initializers. Transforms this:
|
|
92880
92950
|
//
|
|
92881
92951
|
// public x = 1;
|
|
@@ -92886,31 +92956,59 @@ var ts;
|
|
|
92886
92956
|
// this.x = 1;
|
|
92887
92957
|
// }
|
|
92888
92958
|
//
|
|
92959
|
+
// If we do useDefineForClassFields, they'll be converted elsewhere.
|
|
92960
|
+
// We instead *remove* them from the transformed output at this stage.
|
|
92961
|
+
var parameterPropertyDeclarationCount = 0;
|
|
92889
92962
|
if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
|
|
92890
|
-
|
|
92891
|
-
|
|
92892
|
-
afterParameterProperties = constructor.body.statements.length;
|
|
92963
|
+
if (useDefineForClassFields) {
|
|
92964
|
+
statements = statements.filter(function (statement) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor); });
|
|
92893
92965
|
}
|
|
92894
|
-
|
|
92895
|
-
|
|
92896
|
-
|
|
92966
|
+
else {
|
|
92967
|
+
for (var _i = 0, _b = constructor.body.statements; _i < _b.length; _i++) {
|
|
92968
|
+
var statement = _b[_i];
|
|
92969
|
+
if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
|
|
92970
|
+
parameterPropertyDeclarationCount++;
|
|
92971
|
+
}
|
|
92972
|
+
}
|
|
92973
|
+
if (parameterPropertyDeclarationCount > 0) {
|
|
92974
|
+
var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
|
|
92975
|
+
// If there was a super() call found, add parameter properties immediately after it
|
|
92976
|
+
if (superStatementIndex >= 0) {
|
|
92977
|
+
ts.addRange(statements, parameterProperties);
|
|
92978
|
+
}
|
|
92979
|
+
// If a synthetic super() call was added, add them just after it
|
|
92980
|
+
else if (needsSyntheticConstructor) {
|
|
92981
|
+
statements = __spreadArray(__spreadArray([
|
|
92982
|
+
statements[0]
|
|
92983
|
+
], parameterProperties, true), statements.slice(1), true);
|
|
92984
|
+
}
|
|
92985
|
+
// Since there wasn't a super() call, add them to the top of the constructor
|
|
92986
|
+
else {
|
|
92987
|
+
statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
|
|
92988
|
+
}
|
|
92989
|
+
indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
|
|
92897
92990
|
}
|
|
92898
|
-
indexOfFirstStatement = afterParameterProperties;
|
|
92899
92991
|
}
|
|
92900
92992
|
}
|
|
92901
92993
|
var receiver = factory.createThis();
|
|
92902
92994
|
// private methods can be called in property initializers, they should execute first.
|
|
92903
92995
|
addMethodStatements(statements, privateMethodsAndAccessors, receiver);
|
|
92904
92996
|
addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
|
|
92905
|
-
// Add existing statements
|
|
92997
|
+
// Add existing statements after the initial prologues and super call
|
|
92906
92998
|
if (constructor) {
|
|
92907
|
-
ts.addRange(statements, ts.visitNodes(constructor.body.statements,
|
|
92999
|
+
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
|
|
92908
93000
|
}
|
|
92909
93001
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
92910
93002
|
return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
|
|
92911
93003
|
/*location*/ constructor ? constructor.body.statements : node.members),
|
|
92912
93004
|
/*multiLine*/ true),
|
|
92913
93005
|
/*location*/ constructor ? constructor.body : undefined);
|
|
93006
|
+
function visitBodyStatement(statement) {
|
|
93007
|
+
if (useDefineForClassFields && ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
|
|
93008
|
+
return undefined;
|
|
93009
|
+
}
|
|
93010
|
+
return visitor(statement);
|
|
93011
|
+
}
|
|
92914
93012
|
}
|
|
92915
93013
|
/**
|
|
92916
93014
|
* Generates assignment statements for property initializers.
|
|
@@ -96702,37 +96800,39 @@ var ts;
|
|
|
96702
96800
|
var prologue = [];
|
|
96703
96801
|
var statements = [];
|
|
96704
96802
|
resumeLexicalEnvironment();
|
|
96803
|
+
// In derived classes, there may be code before the necessary super() call
|
|
96804
|
+
// We'll remove pre-super statements to be tacked on after the rest of the body
|
|
96805
|
+
var existingPrologue = ts.takeWhile(constructor.body.statements, ts.isPrologueDirective);
|
|
96806
|
+
var _a = findSuperCallAndStatementIndex(constructor.body.statements, existingPrologue), superCall = _a.superCall, superStatementIndex = _a.superStatementIndex;
|
|
96807
|
+
var postSuperStatementsStart = superStatementIndex === -1 ? existingPrologue.length : superStatementIndex + 1;
|
|
96705
96808
|
// If a super call has already been synthesized,
|
|
96706
96809
|
// we're going to assume that we should just transform everything after that.
|
|
96707
96810
|
// The assumption is that no prior step in the pipeline has added any prologue directives.
|
|
96708
|
-
var statementOffset =
|
|
96811
|
+
var statementOffset = postSuperStatementsStart;
|
|
96709
96812
|
if (!hasSynthesizedSuper)
|
|
96710
|
-
statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, /*ensureUseStrict*/ false);
|
|
96711
|
-
addDefaultValueAssignmentsIfNeeded(statements, constructor);
|
|
96712
|
-
addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
|
|
96813
|
+
statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, statementOffset, /*ensureUseStrict*/ false);
|
|
96713
96814
|
if (!hasSynthesizedSuper)
|
|
96714
|
-
statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor);
|
|
96715
|
-
// If
|
|
96815
|
+
statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor, /*filter*/ undefined);
|
|
96816
|
+
// If there already exists a call to `super()`, visit the statement directly
|
|
96716
96817
|
var superCallExpression;
|
|
96717
96818
|
if (hasSynthesizedSuper) {
|
|
96718
96819
|
superCallExpression = createDefaultSuperCallOrThis();
|
|
96719
96820
|
}
|
|
96720
|
-
else if (
|
|
96721
|
-
|
|
96722
|
-
if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
|
|
96723
|
-
superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
|
|
96724
|
-
}
|
|
96821
|
+
else if (superCall) {
|
|
96822
|
+
superCallExpression = visitSuperCallInBody(superCall);
|
|
96725
96823
|
}
|
|
96726
96824
|
if (superCallExpression) {
|
|
96727
96825
|
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
96728
|
-
statementOffset++; // skip this statement, we will add it after visiting the rest of the body.
|
|
96729
96826
|
}
|
|
96827
|
+
// Add parameter defaults at the beginning of the output, with prologue statements
|
|
96828
|
+
addDefaultValueAssignmentsIfNeeded(prologue, constructor);
|
|
96829
|
+
addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
|
|
96730
96830
|
// visit the remaining statements
|
|
96731
96831
|
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset));
|
|
96732
96832
|
factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
|
|
96733
96833
|
insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
|
|
96734
|
-
if (isDerivedClass) {
|
|
96735
|
-
if (superCallExpression &&
|
|
96834
|
+
if (isDerivedClass || superCallExpression) {
|
|
96835
|
+
if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
|
|
96736
96836
|
// If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
|
|
96737
96837
|
// following representation:
|
|
96738
96838
|
//
|
|
@@ -96752,10 +96852,10 @@ var ts;
|
|
|
96752
96852
|
// return C;
|
|
96753
96853
|
// })(Base);
|
|
96754
96854
|
// ```
|
|
96755
|
-
var
|
|
96855
|
+
var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
|
|
96756
96856
|
var returnStatement = factory.createReturnStatement(superCallExpression);
|
|
96757
|
-
ts.setCommentRange(returnStatement, ts.getCommentRange(
|
|
96758
|
-
ts.setEmitFlags(
|
|
96857
|
+
ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1));
|
|
96858
|
+
ts.setEmitFlags(superCall_1, 1536 /* NoComments */);
|
|
96759
96859
|
statements.push(returnStatement);
|
|
96760
96860
|
}
|
|
96761
96861
|
else {
|
|
@@ -96780,9 +96880,19 @@ var ts;
|
|
|
96780
96880
|
// return C;
|
|
96781
96881
|
// })(Base);
|
|
96782
96882
|
// ```
|
|
96783
|
-
//
|
|
96784
|
-
|
|
96785
|
-
|
|
96883
|
+
// If the super() call is the first statement, we can directly create and assign its result to `_this`
|
|
96884
|
+
if (superStatementIndex <= existingPrologue.length) {
|
|
96885
|
+
insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
|
|
96886
|
+
}
|
|
96887
|
+
// Since the `super()` call isn't the first statement, it's split across 1-2 statements:
|
|
96888
|
+
// * A prologue `var _this = this;`, in case the constructor accesses this before super()
|
|
96889
|
+
// * If it exists, a reassignment to that `_this` of the super() call
|
|
96890
|
+
else {
|
|
96891
|
+
insertCaptureThisForNode(prologue, constructor, createActualThis());
|
|
96892
|
+
if (superCallExpression) {
|
|
96893
|
+
insertSuperThisCaptureThisForNode(statements, superCallExpression);
|
|
96894
|
+
}
|
|
96895
|
+
}
|
|
96786
96896
|
if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
|
|
96787
96897
|
statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)));
|
|
96788
96898
|
}
|
|
@@ -96805,11 +96915,27 @@ var ts;
|
|
|
96805
96915
|
// ```
|
|
96806
96916
|
insertCaptureThisForNodeIfNeeded(prologue, constructor);
|
|
96807
96917
|
}
|
|
96808
|
-
var
|
|
96918
|
+
var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)),
|
|
96809
96919
|
/*location*/ constructor.body.statements),
|
|
96810
96920
|
/*multiLine*/ true);
|
|
96811
|
-
ts.setTextRange(
|
|
96812
|
-
return
|
|
96921
|
+
ts.setTextRange(body, constructor.body);
|
|
96922
|
+
return body;
|
|
96923
|
+
}
|
|
96924
|
+
function findSuperCallAndStatementIndex(originalBodyStatements, existingPrologue) {
|
|
96925
|
+
for (var i = existingPrologue.length; i < originalBodyStatements.length; i += 1) {
|
|
96926
|
+
var superCall = ts.getSuperCallFromStatement(originalBodyStatements[i]);
|
|
96927
|
+
if (superCall) {
|
|
96928
|
+
// With a super() call, split the statements into pre-super() and 'body' (post-super())
|
|
96929
|
+
return {
|
|
96930
|
+
superCall: superCall,
|
|
96931
|
+
superStatementIndex: i,
|
|
96932
|
+
};
|
|
96933
|
+
}
|
|
96934
|
+
}
|
|
96935
|
+
// Since there was no super() call found, consider all statements to be in the main 'body' (post-super())
|
|
96936
|
+
return {
|
|
96937
|
+
superStatementIndex: -1,
|
|
96938
|
+
};
|
|
96813
96939
|
}
|
|
96814
96940
|
/**
|
|
96815
96941
|
* We want to try to avoid emitting a return statement in certain cases if a user already returned something.
|
|
@@ -97038,6 +97164,18 @@ var ts;
|
|
|
97038
97164
|
}
|
|
97039
97165
|
return false;
|
|
97040
97166
|
}
|
|
97167
|
+
/**
|
|
97168
|
+
* Assigns the `this` in a constructor to the result of its `super()` call.
|
|
97169
|
+
*
|
|
97170
|
+
* @param statements Statements in the constructor body.
|
|
97171
|
+
* @param superExpression Existing `super()` call for the constructor.
|
|
97172
|
+
*/
|
|
97173
|
+
function insertSuperThisCaptureThisForNode(statements, superExpression) {
|
|
97174
|
+
enableSubstitutionsForCapturedThis();
|
|
97175
|
+
var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression));
|
|
97176
|
+
ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression);
|
|
97177
|
+
ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent);
|
|
97178
|
+
}
|
|
97041
97179
|
function insertCaptureThisForNode(statements, node, initializer) {
|
|
97042
97180
|
enableSubstitutionsForCapturedThis();
|
|
97043
97181
|
var captureThisStatement = factory.createVariableStatement(
|
|
@@ -97347,7 +97485,7 @@ var ts;
|
|
|
97347
97485
|
if (ts.isBlock(body)) {
|
|
97348
97486
|
// ensureUseStrict is false because no new prologue-directive should be added.
|
|
97349
97487
|
// addStandardPrologue will put already-existing directives at the beginning of the target statement-array
|
|
97350
|
-
statementOffset = factory.copyStandardPrologue(body.statements, prologue, /*ensureUseStrict*/ false);
|
|
97488
|
+
statementOffset = factory.copyStandardPrologue(body.statements, prologue, 0, /*ensureUseStrict*/ false);
|
|
97351
97489
|
statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedFunction);
|
|
97352
97490
|
statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedVariableStatement);
|
|
97353
97491
|
}
|
|
@@ -98718,7 +98856,7 @@ var ts;
|
|
|
98718
98856
|
/*type*/ undefined, factory.updateBlock(func.body, statements))),
|
|
98719
98857
|
/*typeArguments*/ undefined, call.arguments))));
|
|
98720
98858
|
}
|
|
98721
|
-
function
|
|
98859
|
+
function visitSuperCallInBody(node) {
|
|
98722
98860
|
return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false);
|
|
98723
98861
|
}
|
|
98724
98862
|
function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
|
|
@@ -119946,8 +120084,8 @@ var ts;
|
|
|
119946
120084
|
}
|
|
119947
120085
|
function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
|
|
119948
120086
|
return ts.firstDefined(rootDirs, function (rootDir) {
|
|
119949
|
-
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
119950
|
-
return isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
120087
|
+
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
120088
|
+
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
119951
120089
|
});
|
|
119952
120090
|
}
|
|
119953
120091
|
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
@@ -128975,7 +129113,7 @@ var ts;
|
|
|
128975
129113
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
128976
129114
|
}
|
|
128977
129115
|
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
|
|
128978
|
-
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
129116
|
+
var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
|
|
128979
129117
|
// Verify if the file is JSX language variant
|
|
128980
129118
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
128981
129119
|
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
|
|
@@ -128986,7 +129124,7 @@ var ts;
|
|
|
128986
129124
|
var entries = ts.createSortedArray();
|
|
128987
129125
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
128988
129126
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
128989
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
129127
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
128990
129128
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
|
|
128991
129129
|
}
|
|
128992
129130
|
else {
|
|
@@ -128994,7 +129132,7 @@ var ts;
|
|
|
128994
129132
|
return undefined;
|
|
128995
129133
|
}
|
|
128996
129134
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
128997
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
129135
|
+
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
128998
129136
|
}
|
|
128999
129137
|
if (keywordFilters !== 0 /* None */) {
|
|
129000
129138
|
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -129100,7 +129238,7 @@ var ts;
|
|
|
129100
129238
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
129101
129239
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
129102
129240
|
}
|
|
129103
|
-
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext) {
|
|
129241
|
+
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
129104
129242
|
var _a, _b;
|
|
129105
129243
|
var insertText;
|
|
129106
129244
|
var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
|
|
@@ -129171,8 +129309,7 @@ var ts;
|
|
|
129171
129309
|
source = CompletionSource.ClassMemberSnippet;
|
|
129172
129310
|
}
|
|
129173
129311
|
}
|
|
129174
|
-
|
|
129175
|
-
if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
129312
|
+
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
129176
129313
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
129177
129314
|
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
129178
129315
|
// If is boolean like or undefined, don't return a snippet we want just to return the completion.
|
|
@@ -129210,7 +129347,7 @@ var ts;
|
|
|
129210
129347
|
// entries (like JavaScript identifier entries).
|
|
129211
129348
|
return {
|
|
129212
129349
|
name: name,
|
|
129213
|
-
kind:
|
|
129350
|
+
kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location),
|
|
129214
129351
|
kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol),
|
|
129215
129352
|
sortText: sortText,
|
|
129216
129353
|
source: source,
|
|
@@ -129506,7 +129643,7 @@ var ts;
|
|
|
129506
129643
|
return CompletionSource.ThisProperty;
|
|
129507
129644
|
}
|
|
129508
129645
|
}
|
|
129509
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
|
|
129646
|
+
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
129510
129647
|
var _a;
|
|
129511
129648
|
var start = ts.timestamp();
|
|
129512
129649
|
var variableDeclaration = getVariableDeclaration(location);
|
|
@@ -129527,7 +129664,7 @@ var ts;
|
|
|
129527
129664
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
129528
129665
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
129529
129666
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
129530
|
-
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext);
|
|
129667
|
+
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag);
|
|
129531
129668
|
if (!entry) {
|
|
129532
129669
|
continue;
|
|
129533
129670
|
}
|
|
@@ -130121,6 +130258,7 @@ var ts;
|
|
|
130121
130258
|
symbolToSortTextIdMap: symbolToSortTextIdMap,
|
|
130122
130259
|
isTypeOnlyLocation: isTypeOnlyLocation,
|
|
130123
130260
|
isJsxIdentifierExpected: isJsxIdentifierExpected,
|
|
130261
|
+
isRightOfOpenTag: isRightOfOpenTag,
|
|
130124
130262
|
importCompletionNode: importCompletionNode,
|
|
130125
130263
|
hasUnresolvedAutoImports: hasUnresolvedAutoImports,
|
|
130126
130264
|
};
|
|
@@ -146230,20 +146368,31 @@ var ts;
|
|
|
146230
146368
|
codefix.registerCodeFix({
|
|
146231
146369
|
errorCodes: errorCodes,
|
|
146232
146370
|
getCodeActions: function getCodeActionsToAddConvertToUnknownForNonOverlappingTypes(context) {
|
|
146233
|
-
var
|
|
146371
|
+
var assertion = getAssertion(context.sourceFile, context.span.start);
|
|
146372
|
+
if (assertion === undefined)
|
|
146373
|
+
return undefined;
|
|
146374
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, assertion); });
|
|
146234
146375
|
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_unknown_conversion_for_non_overlapping_types, fixId, ts.Diagnostics.Add_unknown_to_all_conversions_of_non_overlapping_types)];
|
|
146235
146376
|
},
|
|
146236
146377
|
fixIds: [fixId],
|
|
146237
|
-
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
146378
|
+
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
146379
|
+
var assertion = getAssertion(diag.file, diag.start);
|
|
146380
|
+
if (assertion) {
|
|
146381
|
+
makeChange(changes, diag.file, assertion);
|
|
146382
|
+
}
|
|
146383
|
+
}); },
|
|
146238
146384
|
});
|
|
146239
|
-
function makeChange(changeTracker, sourceFile,
|
|
146240
|
-
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
146241
|
-
var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); }), "Expected to find an assertion expression");
|
|
146385
|
+
function makeChange(changeTracker, sourceFile, assertion) {
|
|
146242
146386
|
var replacement = ts.isAsExpression(assertion)
|
|
146243
146387
|
? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */))
|
|
146244
146388
|
: ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */), assertion.expression);
|
|
146245
146389
|
changeTracker.replaceNode(sourceFile, assertion.expression, replacement);
|
|
146246
146390
|
}
|
|
146391
|
+
function getAssertion(sourceFile, pos) {
|
|
146392
|
+
if (ts.isInJSFile(sourceFile))
|
|
146393
|
+
return undefined;
|
|
146394
|
+
return ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); });
|
|
146395
|
+
}
|
|
146247
146396
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
146248
146397
|
})(ts || (ts = {}));
|
|
146249
146398
|
/* @internal */
|
|
@@ -149361,10 +149510,15 @@ var ts;
|
|
|
149361
149510
|
if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
|
|
149362
149511
|
return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|
|
149363
149512
|
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|
|
149513
|
+
|| ts.compareBooleans(isOnlyDotsAndSlashes(a.moduleSpecifier), isOnlyDotsAndSlashes(b.moduleSpecifier))
|
|
149364
149514
|
|| ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
|
|
149365
149515
|
}
|
|
149366
149516
|
return 0 /* EqualTo */;
|
|
149367
149517
|
}
|
|
149518
|
+
var notDotOrSlashPattern = /[^.\/]/;
|
|
149519
|
+
function isOnlyDotsAndSlashes(path) {
|
|
149520
|
+
return !notDotOrSlashPattern.test(path);
|
|
149521
|
+
}
|
|
149368
149522
|
function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
|
|
149369
149523
|
if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
|
|
149370
149524
|
return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */;
|