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/tsserverlibrary.js
CHANGED
|
@@ -294,7 +294,7 @@ var ts;
|
|
|
294
294
|
// The following is baselined as a literal template type without intervention
|
|
295
295
|
/** The version of the TypeScript compiler release */
|
|
296
296
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
297
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220116";
|
|
298
298
|
/* @internal */
|
|
299
299
|
var Comparison;
|
|
300
300
|
(function (Comparison) {
|
|
@@ -8482,7 +8482,7 @@ var ts;
|
|
|
8482
8482
|
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."),
|
|
8483
8483
|
Duplicate_index_signature_for_type_0: diag(2374, ts.DiagnosticCategory.Error, "Duplicate_index_signature_for_type_0_2374", "Duplicate index signature for type '{0}'."),
|
|
8484
8484
|
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."),
|
|
8485
|
-
|
|
8485
|
+
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."),
|
|
8486
8486
|
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."),
|
|
8487
8487
|
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."),
|
|
8488
8488
|
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."),
|
|
@@ -8505,6 +8505,7 @@ var ts;
|
|
|
8505
8505
|
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."),
|
|
8506
8506
|
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."),
|
|
8507
8507
|
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."),
|
|
8508
|
+
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."),
|
|
8508
8509
|
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."),
|
|
8509
8510
|
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}'."),
|
|
8510
8511
|
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."),
|
|
@@ -15665,6 +15666,34 @@ var ts;
|
|
|
15665
15666
|
}
|
|
15666
15667
|
}
|
|
15667
15668
|
ts.getThisContainer = getThisContainer;
|
|
15669
|
+
/**
|
|
15670
|
+
* @returns Whether the node creates a new 'this' scope for its children.
|
|
15671
|
+
*/
|
|
15672
|
+
function isThisContainerOrFunctionBlock(node) {
|
|
15673
|
+
switch (node.kind) {
|
|
15674
|
+
// Arrow functions use the same scope, but may do so in a "delayed" manner
|
|
15675
|
+
// For example, `const getThis = () => this` may be before a super() call in a derived constructor
|
|
15676
|
+
case 213 /* ArrowFunction */:
|
|
15677
|
+
case 255 /* FunctionDeclaration */:
|
|
15678
|
+
case 212 /* FunctionExpression */:
|
|
15679
|
+
case 166 /* PropertyDeclaration */:
|
|
15680
|
+
return true;
|
|
15681
|
+
case 234 /* Block */:
|
|
15682
|
+
switch (node.parent.kind) {
|
|
15683
|
+
case 170 /* Constructor */:
|
|
15684
|
+
case 168 /* MethodDeclaration */:
|
|
15685
|
+
case 171 /* GetAccessor */:
|
|
15686
|
+
case 172 /* SetAccessor */:
|
|
15687
|
+
// Object properties can have computed names; only method-like bodies start a new scope
|
|
15688
|
+
return true;
|
|
15689
|
+
default:
|
|
15690
|
+
return false;
|
|
15691
|
+
}
|
|
15692
|
+
default:
|
|
15693
|
+
return false;
|
|
15694
|
+
}
|
|
15695
|
+
}
|
|
15696
|
+
ts.isThisContainerOrFunctionBlock = isThisContainerOrFunctionBlock;
|
|
15668
15697
|
function isInTopLevelContext(node) {
|
|
15669
15698
|
// The name of a class or function declaration is a BindingIdentifier in its surrounding scope.
|
|
15670
15699
|
if (ts.isIdentifier(node) && (ts.isClassDeclaration(node.parent) || ts.isFunctionDeclaration(node.parent)) && node.parent.name === node) {
|
|
@@ -26251,7 +26280,7 @@ var ts;
|
|
|
26251
26280
|
* @param visitor Optional callback used to visit any custom prologue directives.
|
|
26252
26281
|
*/
|
|
26253
26282
|
function copyPrologue(source, target, ensureUseStrict, visitor) {
|
|
26254
|
-
var offset = copyStandardPrologue(source, target, ensureUseStrict);
|
|
26283
|
+
var offset = copyStandardPrologue(source, target, 0, ensureUseStrict);
|
|
26255
26284
|
return copyCustomPrologue(source, target, offset, visitor);
|
|
26256
26285
|
}
|
|
26257
26286
|
function isUseStrictPrologue(node) {
|
|
@@ -26264,12 +26293,14 @@ var ts;
|
|
|
26264
26293
|
* Copies only the standard (string-expression) prologue-directives into the target statement-array.
|
|
26265
26294
|
* @param source origin statements array
|
|
26266
26295
|
* @param target result statements array
|
|
26296
|
+
* @param statementOffset The offset at which to begin the copy.
|
|
26267
26297
|
* @param ensureUseStrict boolean determining whether the function need to add prologue-directives
|
|
26298
|
+
* @returns Count of how many directive statements were copied.
|
|
26268
26299
|
*/
|
|
26269
|
-
function copyStandardPrologue(source, target, ensureUseStrict) {
|
|
26300
|
+
function copyStandardPrologue(source, target, statementOffset, ensureUseStrict) {
|
|
26301
|
+
if (statementOffset === void 0) { statementOffset = 0; }
|
|
26270
26302
|
ts.Debug.assert(target.length === 0, "Prologue directives should be at the first statement in the target statements array");
|
|
26271
26303
|
var foundUseStrict = false;
|
|
26272
|
-
var statementOffset = 0;
|
|
26273
26304
|
var numStatements = source.length;
|
|
26274
26305
|
while (statementOffset < numStatements) {
|
|
26275
26306
|
var statement = source[statementOffset];
|
|
@@ -27692,7 +27723,7 @@ var ts;
|
|
|
27692
27723
|
importName: "__createBinding",
|
|
27693
27724
|
scoped: false,
|
|
27694
27725
|
priority: 1,
|
|
27695
|
-
text: "\n var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n if (k2 === undefined) k2 = k;\n Object.
|
|
27726
|
+
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 }));"
|
|
27696
27727
|
};
|
|
27697
27728
|
ts.setModuleDefaultHelper = {
|
|
27698
27729
|
name: "typescript:commonjscreatevalue",
|
|
@@ -41327,7 +41358,7 @@ var ts;
|
|
|
41327
41358
|
? 1 /* Recursive */ : 0 /* None */
|
|
41328
41359
|
};
|
|
41329
41360
|
}
|
|
41330
|
-
if (ts.isImplicitGlob(spec)) {
|
|
41361
|
+
if (ts.isImplicitGlob(spec.substring(spec.lastIndexOf(ts.directorySeparator) + 1))) {
|
|
41331
41362
|
return {
|
|
41332
41363
|
key: useCaseSensitiveFileNames ? spec : ts.toFileNameLowerCase(spec),
|
|
41333
41364
|
flags: 1 /* Recursive */
|
|
@@ -78712,32 +78743,38 @@ var ts;
|
|
|
78712
78743
|
if (classExtendsNull) {
|
|
78713
78744
|
error(superCall, ts.Diagnostics.A_constructor_cannot_contain_a_super_call_when_its_class_extends_null);
|
|
78714
78745
|
}
|
|
78715
|
-
//
|
|
78716
|
-
// if both of the following are true:
|
|
78746
|
+
// A super call must be root-level in a constructor if both of the following are true:
|
|
78717
78747
|
// - The containing class is a derived class.
|
|
78718
78748
|
// - The constructor declares parameter properties
|
|
78719
78749
|
// or the containing class declares instance member variables with initializers.
|
|
78720
|
-
var
|
|
78750
|
+
var superCallShouldBeRootLevel = (ts.getEmitScriptTarget(compilerOptions) !== 99 /* ESNext */ || !useDefineForClassFields) &&
|
|
78721
78751
|
(ts.some(node.parent.members, isInstancePropertyWithInitializerOrPrivateIdentifierProperty) ||
|
|
78722
78752
|
ts.some(node.parameters, function (p) { return ts.hasSyntacticModifier(p, 16476 /* ParameterPropertyModifier */); }));
|
|
78723
|
-
|
|
78724
|
-
|
|
78725
|
-
|
|
78726
|
-
|
|
78727
|
-
|
|
78728
|
-
|
|
78729
|
-
|
|
78730
|
-
|
|
78731
|
-
|
|
78732
|
-
|
|
78753
|
+
if (superCallShouldBeRootLevel) {
|
|
78754
|
+
// Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
|
|
78755
|
+
// See GH #8277
|
|
78756
|
+
if (!superCallIsRootLevelInConstructor(superCall, node.body)) {
|
|
78757
|
+
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);
|
|
78758
|
+
}
|
|
78759
|
+
// Skip past any prologue directives to check statements for referring to 'super' or 'this' before a super call
|
|
78760
|
+
else {
|
|
78761
|
+
var superCallStatement = void 0;
|
|
78762
|
+
for (var _i = 0, _a = node.body.statements; _i < _a.length; _i++) {
|
|
78763
|
+
var statement = _a[_i];
|
|
78764
|
+
if (ts.isExpressionStatement(statement) && ts.isSuperCall(ts.skipOuterExpressions(statement.expression))) {
|
|
78765
|
+
superCallStatement = statement;
|
|
78766
|
+
break;
|
|
78767
|
+
}
|
|
78768
|
+
if (!ts.isPrologueDirective(statement) && nodeImmediatelyReferencesSuperOrThis(statement)) {
|
|
78769
|
+
break;
|
|
78770
|
+
}
|
|
78733
78771
|
}
|
|
78734
|
-
|
|
78735
|
-
|
|
78772
|
+
// Until we have better flow analysis, it is an error to place the super call within any kind of block or conditional
|
|
78773
|
+
// See GH #8277
|
|
78774
|
+
if (superCallStatement === undefined) {
|
|
78775
|
+
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);
|
|
78736
78776
|
}
|
|
78737
78777
|
}
|
|
78738
|
-
if (!superCallStatement) {
|
|
78739
|
-
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);
|
|
78740
|
-
}
|
|
78741
78778
|
}
|
|
78742
78779
|
}
|
|
78743
78780
|
else if (!classExtendsNull) {
|
|
@@ -78745,6 +78782,19 @@ var ts;
|
|
|
78745
78782
|
}
|
|
78746
78783
|
}
|
|
78747
78784
|
}
|
|
78785
|
+
function superCallIsRootLevelInConstructor(superCall, body) {
|
|
78786
|
+
var superCallParent = ts.walkUpParenthesizedExpressions(superCall.parent);
|
|
78787
|
+
return ts.isExpressionStatement(superCallParent) && superCallParent.parent === body;
|
|
78788
|
+
}
|
|
78789
|
+
function nodeImmediatelyReferencesSuperOrThis(node) {
|
|
78790
|
+
if (node.kind === 106 /* SuperKeyword */ || node.kind === 108 /* ThisKeyword */) {
|
|
78791
|
+
return true;
|
|
78792
|
+
}
|
|
78793
|
+
if (ts.isThisContainerOrFunctionBlock(node)) {
|
|
78794
|
+
return false;
|
|
78795
|
+
}
|
|
78796
|
+
return !!ts.forEachChild(node, nodeImmediatelyReferencesSuperOrThis);
|
|
78797
|
+
}
|
|
78748
78798
|
function checkAccessorDeclaration(node) {
|
|
78749
78799
|
if (produceDiagnostics) {
|
|
78750
78800
|
// Grammar checking accessors
|
|
@@ -88867,34 +88917,31 @@ var ts;
|
|
|
88867
88917
|
}
|
|
88868
88918
|
ts.getNonAssignmentOperatorForCompoundAssignment = getNonAssignmentOperatorForCompoundAssignment;
|
|
88869
88919
|
/**
|
|
88870
|
-
*
|
|
88871
|
-
|
|
88872
|
-
|
|
88873
|
-
|
|
88874
|
-
|
|
88875
|
-
|
|
88920
|
+
* @returns Contained super() call from descending into the statement ignoring parentheses, if that call exists.
|
|
88921
|
+
*/
|
|
88922
|
+
function getSuperCallFromStatement(statement) {
|
|
88923
|
+
if (!ts.isExpressionStatement(statement)) {
|
|
88924
|
+
return undefined;
|
|
88925
|
+
}
|
|
88926
|
+
var expression = ts.skipParentheses(statement.expression);
|
|
88927
|
+
return ts.isSuperCall(expression)
|
|
88928
|
+
? expression
|
|
88929
|
+
: undefined;
|
|
88930
|
+
}
|
|
88931
|
+
ts.getSuperCallFromStatement = getSuperCallFromStatement;
|
|
88932
|
+
/**
|
|
88933
|
+
* @returns The index (after prologue statements) of a super call, or -1 if not found.
|
|
88876
88934
|
*/
|
|
88877
|
-
function
|
|
88878
|
-
|
|
88879
|
-
var
|
|
88880
|
-
|
|
88881
|
-
|
|
88882
|
-
if (index === statements.length) {
|
|
88883
|
-
// list contains nothing but prologue directives (or empty) - exit
|
|
88884
|
-
return index;
|
|
88885
|
-
}
|
|
88886
|
-
var superIndex = ts.findIndex(statements, function (s) { return ts.isExpressionStatement(s) && ts.isSuperCall(s.expression); }, index);
|
|
88887
|
-
if (superIndex > -1) {
|
|
88888
|
-
for (var i = index; i <= superIndex; i++) {
|
|
88889
|
-
result.push(ts.visitNode(statements[i], visitor, ts.isStatement));
|
|
88890
|
-
}
|
|
88891
|
-
return superIndex + 1;
|
|
88935
|
+
function findSuperStatementIndex(statements, indexAfterLastPrologueStatement) {
|
|
88936
|
+
for (var i = indexAfterLastPrologueStatement; i < statements.length; i += 1) {
|
|
88937
|
+
var statement = statements[i];
|
|
88938
|
+
if (getSuperCallFromStatement(statement)) {
|
|
88939
|
+
return i;
|
|
88892
88940
|
}
|
|
88893
|
-
return index;
|
|
88894
88941
|
}
|
|
88895
|
-
return
|
|
88942
|
+
return -1;
|
|
88896
88943
|
}
|
|
88897
|
-
ts.
|
|
88944
|
+
ts.findSuperStatementIndex = findSuperStatementIndex;
|
|
88898
88945
|
function getProperties(node, requireInitializer, isStatic) {
|
|
88899
88946
|
return ts.filter(node.members, function (m) { return isInitializedOrStaticProperty(m, requireInitializer, isStatic); });
|
|
88900
88947
|
}
|
|
@@ -90793,6 +90840,7 @@ var ts;
|
|
|
90793
90840
|
case 176 /* TypePredicate */:
|
|
90794
90841
|
case 133 /* BooleanKeyword */:
|
|
90795
90842
|
return factory.createIdentifier("Boolean");
|
|
90843
|
+
case 197 /* TemplateLiteralType */:
|
|
90796
90844
|
case 149 /* StringKeyword */:
|
|
90797
90845
|
return factory.createIdentifier("String");
|
|
90798
90846
|
case 147 /* ObjectKeyword */:
|
|
@@ -91131,10 +91179,14 @@ var ts;
|
|
|
91131
91179
|
return ts.visitFunctionBody(body, visitor, context);
|
|
91132
91180
|
}
|
|
91133
91181
|
var statements = [];
|
|
91134
|
-
var indexOfFirstStatement = 0;
|
|
91135
91182
|
resumeLexicalEnvironment();
|
|
91136
|
-
|
|
91137
|
-
|
|
91183
|
+
var indexAfterLastPrologueStatement = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor);
|
|
91184
|
+
var superStatementIndex = ts.findSuperStatementIndex(body.statements, indexAfterLastPrologueStatement);
|
|
91185
|
+
// If there was a super call, visit existing statements up to and including it
|
|
91186
|
+
if (superStatementIndex >= 0) {
|
|
91187
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, indexAfterLastPrologueStatement, superStatementIndex + 1 - indexAfterLastPrologueStatement));
|
|
91188
|
+
}
|
|
91189
|
+
// Transform parameters into property assignments. Transforms this:
|
|
91138
91190
|
//
|
|
91139
91191
|
// constructor (public x, public y) {
|
|
91140
91192
|
// }
|
|
@@ -91146,9 +91198,17 @@ var ts;
|
|
|
91146
91198
|
// this.y = y;
|
|
91147
91199
|
// }
|
|
91148
91200
|
//
|
|
91149
|
-
|
|
91150
|
-
//
|
|
91151
|
-
|
|
91201
|
+
var parameterPropertyAssignments = ts.mapDefined(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment);
|
|
91202
|
+
// If there is a super() call, the parameter properties go immediately after it
|
|
91203
|
+
if (superStatementIndex >= 0) {
|
|
91204
|
+
ts.addRange(statements, parameterPropertyAssignments);
|
|
91205
|
+
}
|
|
91206
|
+
// Since there was no super() call, parameter properties are the first statements in the constructor
|
|
91207
|
+
else {
|
|
91208
|
+
statements = ts.addRange(parameterPropertyAssignments, statements);
|
|
91209
|
+
}
|
|
91210
|
+
// Add remaining statements from the body, skipping the super() call if it was found
|
|
91211
|
+
ts.addRange(statements, ts.visitNodes(body.statements, visitor, ts.isStatement, superStatementIndex + 1));
|
|
91152
91212
|
// End the lexical environment.
|
|
91153
91213
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
91154
91214
|
var block = factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true);
|
|
@@ -93046,6 +93106,7 @@ var ts;
|
|
|
93046
93106
|
/*modifiers*/ undefined, parameters !== null && parameters !== void 0 ? parameters : [], body), constructor || node), constructor));
|
|
93047
93107
|
}
|
|
93048
93108
|
function transformConstructorBody(node, constructor, isDerivedClass) {
|
|
93109
|
+
var _a;
|
|
93049
93110
|
var properties = ts.getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false);
|
|
93050
93111
|
if (!useDefineForClassFields) {
|
|
93051
93112
|
properties = ts.filter(properties, function (property) { return !!property.initializer || ts.isPrivateIdentifier(property.name); });
|
|
@@ -93057,9 +93118,21 @@ var ts;
|
|
|
93057
93118
|
return ts.visitFunctionBody(/*node*/ undefined, visitor, context);
|
|
93058
93119
|
}
|
|
93059
93120
|
resumeLexicalEnvironment();
|
|
93060
|
-
var
|
|
93121
|
+
var needsSyntheticConstructor = !constructor && isDerivedClass;
|
|
93122
|
+
var indexOfFirstStatementAfterSuper = 0;
|
|
93123
|
+
var prologueStatementCount = 0;
|
|
93124
|
+
var superStatementIndex = -1;
|
|
93061
93125
|
var statements = [];
|
|
93062
|
-
if (
|
|
93126
|
+
if ((_a = constructor === null || constructor === void 0 ? void 0 : constructor.body) === null || _a === void 0 ? void 0 : _a.statements) {
|
|
93127
|
+
prologueStatementCount = factory.copyPrologue(constructor.body.statements, statements, /*ensureUseStrict*/ false, visitor);
|
|
93128
|
+
superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
|
|
93129
|
+
// If there was a super call, visit existing statements up to and including it
|
|
93130
|
+
if (superStatementIndex >= 0) {
|
|
93131
|
+
indexOfFirstStatementAfterSuper = superStatementIndex + 1;
|
|
93132
|
+
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);
|
|
93133
|
+
}
|
|
93134
|
+
}
|
|
93135
|
+
if (needsSyntheticConstructor) {
|
|
93063
93136
|
// Add a synthetic `super` call:
|
|
93064
93137
|
//
|
|
93065
93138
|
// super(...arguments);
|
|
@@ -93067,9 +93140,6 @@ var ts;
|
|
|
93067
93140
|
statements.push(factory.createExpressionStatement(factory.createCallExpression(factory.createSuper(),
|
|
93068
93141
|
/*typeArguments*/ undefined, [factory.createSpreadElement(factory.createIdentifier("arguments"))])));
|
|
93069
93142
|
}
|
|
93070
|
-
if (constructor) {
|
|
93071
|
-
indexOfFirstStatement = ts.addPrologueDirectivesAndInitialSuperCall(factory, constructor, statements, visitor);
|
|
93072
|
-
}
|
|
93073
93143
|
// Add the property initializers. Transforms this:
|
|
93074
93144
|
//
|
|
93075
93145
|
// public x = 1;
|
|
@@ -93080,31 +93150,59 @@ var ts;
|
|
|
93080
93150
|
// this.x = 1;
|
|
93081
93151
|
// }
|
|
93082
93152
|
//
|
|
93153
|
+
// If we do useDefineForClassFields, they'll be converted elsewhere.
|
|
93154
|
+
// We instead *remove* them from the transformed output at this stage.
|
|
93155
|
+
var parameterPropertyDeclarationCount = 0;
|
|
93083
93156
|
if (constructor === null || constructor === void 0 ? void 0 : constructor.body) {
|
|
93084
|
-
|
|
93085
|
-
|
|
93086
|
-
afterParameterProperties = constructor.body.statements.length;
|
|
93157
|
+
if (useDefineForClassFields) {
|
|
93158
|
+
statements = statements.filter(function (statement) { return !ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor); });
|
|
93087
93159
|
}
|
|
93088
|
-
|
|
93089
|
-
|
|
93090
|
-
|
|
93160
|
+
else {
|
|
93161
|
+
for (var _i = 0, _b = constructor.body.statements; _i < _b.length; _i++) {
|
|
93162
|
+
var statement = _b[_i];
|
|
93163
|
+
if (ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
|
|
93164
|
+
parameterPropertyDeclarationCount++;
|
|
93165
|
+
}
|
|
93166
|
+
}
|
|
93167
|
+
if (parameterPropertyDeclarationCount > 0) {
|
|
93168
|
+
var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
|
|
93169
|
+
// If there was a super() call found, add parameter properties immediately after it
|
|
93170
|
+
if (superStatementIndex >= 0) {
|
|
93171
|
+
ts.addRange(statements, parameterProperties);
|
|
93172
|
+
}
|
|
93173
|
+
// If a synthetic super() call was added, add them just after it
|
|
93174
|
+
else if (needsSyntheticConstructor) {
|
|
93175
|
+
statements = __spreadArray(__spreadArray([
|
|
93176
|
+
statements[0]
|
|
93177
|
+
], parameterProperties, true), statements.slice(1), true);
|
|
93178
|
+
}
|
|
93179
|
+
// Since there wasn't a super() call, add them to the top of the constructor
|
|
93180
|
+
else {
|
|
93181
|
+
statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
|
|
93182
|
+
}
|
|
93183
|
+
indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
|
|
93091
93184
|
}
|
|
93092
|
-
indexOfFirstStatement = afterParameterProperties;
|
|
93093
93185
|
}
|
|
93094
93186
|
}
|
|
93095
93187
|
var receiver = factory.createThis();
|
|
93096
93188
|
// private methods can be called in property initializers, they should execute first.
|
|
93097
93189
|
addMethodStatements(statements, privateMethodsAndAccessors, receiver);
|
|
93098
93190
|
addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
|
|
93099
|
-
// Add existing statements
|
|
93191
|
+
// Add existing statements after the initial prologues and super call
|
|
93100
93192
|
if (constructor) {
|
|
93101
|
-
ts.addRange(statements, ts.visitNodes(constructor.body.statements,
|
|
93193
|
+
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
|
|
93102
93194
|
}
|
|
93103
93195
|
statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
|
|
93104
93196
|
return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
|
|
93105
93197
|
/*location*/ constructor ? constructor.body.statements : node.members),
|
|
93106
93198
|
/*multiLine*/ true),
|
|
93107
93199
|
/*location*/ constructor ? constructor.body : undefined);
|
|
93200
|
+
function visitBodyStatement(statement) {
|
|
93201
|
+
if (useDefineForClassFields && ts.isParameterPropertyDeclaration(ts.getOriginalNode(statement), constructor)) {
|
|
93202
|
+
return undefined;
|
|
93203
|
+
}
|
|
93204
|
+
return visitor(statement);
|
|
93205
|
+
}
|
|
93108
93206
|
}
|
|
93109
93207
|
/**
|
|
93110
93208
|
* Generates assignment statements for property initializers.
|
|
@@ -96896,37 +96994,39 @@ var ts;
|
|
|
96896
96994
|
var prologue = [];
|
|
96897
96995
|
var statements = [];
|
|
96898
96996
|
resumeLexicalEnvironment();
|
|
96997
|
+
// In derived classes, there may be code before the necessary super() call
|
|
96998
|
+
// We'll remove pre-super statements to be tacked on after the rest of the body
|
|
96999
|
+
var existingPrologue = ts.takeWhile(constructor.body.statements, ts.isPrologueDirective);
|
|
97000
|
+
var _a = findSuperCallAndStatementIndex(constructor.body.statements, existingPrologue), superCall = _a.superCall, superStatementIndex = _a.superStatementIndex;
|
|
97001
|
+
var postSuperStatementsStart = superStatementIndex === -1 ? existingPrologue.length : superStatementIndex + 1;
|
|
96899
97002
|
// If a super call has already been synthesized,
|
|
96900
97003
|
// we're going to assume that we should just transform everything after that.
|
|
96901
97004
|
// The assumption is that no prior step in the pipeline has added any prologue directives.
|
|
96902
|
-
var statementOffset =
|
|
97005
|
+
var statementOffset = postSuperStatementsStart;
|
|
96903
97006
|
if (!hasSynthesizedSuper)
|
|
96904
|
-
statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, /*ensureUseStrict*/ false);
|
|
96905
|
-
addDefaultValueAssignmentsIfNeeded(statements, constructor);
|
|
96906
|
-
addRestParameterIfNeeded(statements, constructor, hasSynthesizedSuper);
|
|
97007
|
+
statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, statementOffset, /*ensureUseStrict*/ false);
|
|
96907
97008
|
if (!hasSynthesizedSuper)
|
|
96908
|
-
statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor);
|
|
96909
|
-
// If
|
|
97009
|
+
statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor, /*filter*/ undefined);
|
|
97010
|
+
// If there already exists a call to `super()`, visit the statement directly
|
|
96910
97011
|
var superCallExpression;
|
|
96911
97012
|
if (hasSynthesizedSuper) {
|
|
96912
97013
|
superCallExpression = createDefaultSuperCallOrThis();
|
|
96913
97014
|
}
|
|
96914
|
-
else if (
|
|
96915
|
-
|
|
96916
|
-
if (ts.isExpressionStatement(firstStatement) && ts.isSuperCall(firstStatement.expression)) {
|
|
96917
|
-
superCallExpression = visitImmediateSuperCallInBody(firstStatement.expression);
|
|
96918
|
-
}
|
|
97015
|
+
else if (superCall) {
|
|
97016
|
+
superCallExpression = visitSuperCallInBody(superCall);
|
|
96919
97017
|
}
|
|
96920
97018
|
if (superCallExpression) {
|
|
96921
97019
|
hierarchyFacts |= 8192 /* ConstructorWithCapturedSuper */;
|
|
96922
|
-
statementOffset++; // skip this statement, we will add it after visiting the rest of the body.
|
|
96923
97020
|
}
|
|
97021
|
+
// Add parameter defaults at the beginning of the output, with prologue statements
|
|
97022
|
+
addDefaultValueAssignmentsIfNeeded(prologue, constructor);
|
|
97023
|
+
addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper);
|
|
96924
97024
|
// visit the remaining statements
|
|
96925
97025
|
ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, /*start*/ statementOffset));
|
|
96926
97026
|
factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment());
|
|
96927
97027
|
insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false);
|
|
96928
|
-
if (isDerivedClass) {
|
|
96929
|
-
if (superCallExpression &&
|
|
97028
|
+
if (isDerivedClass || superCallExpression) {
|
|
97029
|
+
if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & 8192 /* ContainsLexicalThis */)) {
|
|
96930
97030
|
// If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the
|
|
96931
97031
|
// following representation:
|
|
96932
97032
|
//
|
|
@@ -96946,10 +97046,10 @@ var ts;
|
|
|
96946
97046
|
// return C;
|
|
96947
97047
|
// })(Base);
|
|
96948
97048
|
// ```
|
|
96949
|
-
var
|
|
97049
|
+
var superCall_1 = ts.cast(ts.cast(superCallExpression, ts.isBinaryExpression).left, ts.isCallExpression);
|
|
96950
97050
|
var returnStatement = factory.createReturnStatement(superCallExpression);
|
|
96951
|
-
ts.setCommentRange(returnStatement, ts.getCommentRange(
|
|
96952
|
-
ts.setEmitFlags(
|
|
97051
|
+
ts.setCommentRange(returnStatement, ts.getCommentRange(superCall_1));
|
|
97052
|
+
ts.setEmitFlags(superCall_1, 1536 /* NoComments */);
|
|
96953
97053
|
statements.push(returnStatement);
|
|
96954
97054
|
}
|
|
96955
97055
|
else {
|
|
@@ -96974,9 +97074,19 @@ var ts;
|
|
|
96974
97074
|
// return C;
|
|
96975
97075
|
// })(Base);
|
|
96976
97076
|
// ```
|
|
96977
|
-
//
|
|
96978
|
-
|
|
96979
|
-
|
|
97077
|
+
// If the super() call is the first statement, we can directly create and assign its result to `_this`
|
|
97078
|
+
if (superStatementIndex <= existingPrologue.length) {
|
|
97079
|
+
insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis());
|
|
97080
|
+
}
|
|
97081
|
+
// Since the `super()` call isn't the first statement, it's split across 1-2 statements:
|
|
97082
|
+
// * A prologue `var _this = this;`, in case the constructor accesses this before super()
|
|
97083
|
+
// * If it exists, a reassignment to that `_this` of the super() call
|
|
97084
|
+
else {
|
|
97085
|
+
insertCaptureThisForNode(prologue, constructor, createActualThis());
|
|
97086
|
+
if (superCallExpression) {
|
|
97087
|
+
insertSuperThisCaptureThisForNode(statements, superCallExpression);
|
|
97088
|
+
}
|
|
97089
|
+
}
|
|
96980
97090
|
if (!isSufficientlyCoveredByReturnStatements(constructor.body)) {
|
|
96981
97091
|
statements.push(factory.createReturnStatement(factory.createUniqueName("_this", 16 /* Optimistic */ | 32 /* FileLevel */)));
|
|
96982
97092
|
}
|
|
@@ -96999,11 +97109,27 @@ var ts;
|
|
|
96999
97109
|
// ```
|
|
97000
97110
|
insertCaptureThisForNodeIfNeeded(prologue, constructor);
|
|
97001
97111
|
}
|
|
97002
|
-
var
|
|
97112
|
+
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)),
|
|
97003
97113
|
/*location*/ constructor.body.statements),
|
|
97004
97114
|
/*multiLine*/ true);
|
|
97005
|
-
ts.setTextRange(
|
|
97006
|
-
return
|
|
97115
|
+
ts.setTextRange(body, constructor.body);
|
|
97116
|
+
return body;
|
|
97117
|
+
}
|
|
97118
|
+
function findSuperCallAndStatementIndex(originalBodyStatements, existingPrologue) {
|
|
97119
|
+
for (var i = existingPrologue.length; i < originalBodyStatements.length; i += 1) {
|
|
97120
|
+
var superCall = ts.getSuperCallFromStatement(originalBodyStatements[i]);
|
|
97121
|
+
if (superCall) {
|
|
97122
|
+
// With a super() call, split the statements into pre-super() and 'body' (post-super())
|
|
97123
|
+
return {
|
|
97124
|
+
superCall: superCall,
|
|
97125
|
+
superStatementIndex: i,
|
|
97126
|
+
};
|
|
97127
|
+
}
|
|
97128
|
+
}
|
|
97129
|
+
// Since there was no super() call found, consider all statements to be in the main 'body' (post-super())
|
|
97130
|
+
return {
|
|
97131
|
+
superStatementIndex: -1,
|
|
97132
|
+
};
|
|
97007
97133
|
}
|
|
97008
97134
|
/**
|
|
97009
97135
|
* We want to try to avoid emitting a return statement in certain cases if a user already returned something.
|
|
@@ -97232,6 +97358,18 @@ var ts;
|
|
|
97232
97358
|
}
|
|
97233
97359
|
return false;
|
|
97234
97360
|
}
|
|
97361
|
+
/**
|
|
97362
|
+
* Assigns the `this` in a constructor to the result of its `super()` call.
|
|
97363
|
+
*
|
|
97364
|
+
* @param statements Statements in the constructor body.
|
|
97365
|
+
* @param superExpression Existing `super()` call for the constructor.
|
|
97366
|
+
*/
|
|
97367
|
+
function insertSuperThisCaptureThisForNode(statements, superExpression) {
|
|
97368
|
+
enableSubstitutionsForCapturedThis();
|
|
97369
|
+
var assignSuperExpression = factory.createExpressionStatement(factory.createBinaryExpression(factory.createThis(), 63 /* EqualsToken */, superExpression));
|
|
97370
|
+
ts.insertStatementAfterCustomPrologue(statements, assignSuperExpression);
|
|
97371
|
+
ts.setCommentRange(assignSuperExpression, ts.getOriginalNode(superExpression).parent);
|
|
97372
|
+
}
|
|
97235
97373
|
function insertCaptureThisForNode(statements, node, initializer) {
|
|
97236
97374
|
enableSubstitutionsForCapturedThis();
|
|
97237
97375
|
var captureThisStatement = factory.createVariableStatement(
|
|
@@ -97541,7 +97679,7 @@ var ts;
|
|
|
97541
97679
|
if (ts.isBlock(body)) {
|
|
97542
97680
|
// ensureUseStrict is false because no new prologue-directive should be added.
|
|
97543
97681
|
// addStandardPrologue will put already-existing directives at the beginning of the target statement-array
|
|
97544
|
-
statementOffset = factory.copyStandardPrologue(body.statements, prologue, /*ensureUseStrict*/ false);
|
|
97682
|
+
statementOffset = factory.copyStandardPrologue(body.statements, prologue, 0, /*ensureUseStrict*/ false);
|
|
97545
97683
|
statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedFunction);
|
|
97546
97684
|
statementOffset = factory.copyCustomPrologue(body.statements, statements, statementOffset, visitor, ts.isHoistedVariableStatement);
|
|
97547
97685
|
}
|
|
@@ -98912,7 +99050,7 @@ var ts;
|
|
|
98912
99050
|
/*type*/ undefined, factory.updateBlock(func.body, statements))),
|
|
98913
99051
|
/*typeArguments*/ undefined, call.arguments))));
|
|
98914
99052
|
}
|
|
98915
|
-
function
|
|
99053
|
+
function visitSuperCallInBody(node) {
|
|
98916
99054
|
return visitCallExpressionWithPotentialCapturedThisAssignment(node, /*assignToCapturedThis*/ false);
|
|
98917
99055
|
}
|
|
98918
99056
|
function visitCallExpressionWithPotentialCapturedThisAssignment(node, assignToCapturedThis) {
|
|
@@ -120140,8 +120278,8 @@ var ts;
|
|
|
120140
120278
|
}
|
|
120141
120279
|
function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
|
|
120142
120280
|
return ts.firstDefined(rootDirs, function (rootDir) {
|
|
120143
|
-
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
120144
|
-
return isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
120281
|
+
var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
|
|
120282
|
+
return relativePath !== undefined && isPathRelativeToParent(relativePath) ? undefined : relativePath;
|
|
120145
120283
|
});
|
|
120146
120284
|
}
|
|
120147
120285
|
function removeExtensionAndIndexPostFix(fileName, ending, options) {
|
|
@@ -129586,7 +129724,7 @@ var ts;
|
|
|
129586
129724
|
return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
|
|
129587
129725
|
}
|
|
129588
129726
|
function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
|
|
129589
|
-
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;
|
|
129727
|
+
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;
|
|
129590
129728
|
// Verify if the file is JSX language variant
|
|
129591
129729
|
if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
|
|
129592
129730
|
var completionInfo = getJsxClosingTagCompletion(location, sourceFile);
|
|
@@ -129597,7 +129735,7 @@ var ts;
|
|
|
129597
129735
|
var entries = ts.createSortedArray();
|
|
129598
129736
|
if (isUncheckedFile(sourceFile, compilerOptions)) {
|
|
129599
129737
|
var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
|
|
129600
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
129738
|
+
/*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);
|
|
129601
129739
|
getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
|
|
129602
129740
|
}
|
|
129603
129741
|
else {
|
|
@@ -129605,7 +129743,7 @@ var ts;
|
|
|
129605
129743
|
return undefined;
|
|
129606
129744
|
}
|
|
129607
129745
|
getCompletionEntriesFromSymbols(symbols, entries,
|
|
129608
|
-
/*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
|
|
129746
|
+
/*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);
|
|
129609
129747
|
}
|
|
129610
129748
|
if (keywordFilters !== 0 /* None */) {
|
|
129611
129749
|
var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
|
|
@@ -129711,7 +129849,7 @@ var ts;
|
|
|
129711
129849
|
function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
|
|
129712
129850
|
return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
|
|
129713
129851
|
}
|
|
129714
|
-
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext) {
|
|
129852
|
+
function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind, formatContext, isJsxIdentifierExpected, isRightOfOpenTag) {
|
|
129715
129853
|
var _a, _b;
|
|
129716
129854
|
var insertText;
|
|
129717
129855
|
var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
|
|
@@ -129782,8 +129920,7 @@ var ts;
|
|
|
129782
129920
|
source = CompletionSource.ClassMemberSnippet;
|
|
129783
129921
|
}
|
|
129784
129922
|
}
|
|
129785
|
-
|
|
129786
|
-
if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
129923
|
+
if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
|
|
129787
129924
|
var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
|
|
129788
129925
|
var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
|
|
129789
129926
|
// If is boolean like or undefined, don't return a snippet we want just to return the completion.
|
|
@@ -129821,7 +129958,7 @@ var ts;
|
|
|
129821
129958
|
// entries (like JavaScript identifier entries).
|
|
129822
129959
|
return {
|
|
129823
129960
|
name: name,
|
|
129824
|
-
kind:
|
|
129961
|
+
kind: ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location),
|
|
129825
129962
|
kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol),
|
|
129826
129963
|
sortText: sortText,
|
|
129827
129964
|
source: source,
|
|
@@ -130117,7 +130254,7 @@ var ts;
|
|
|
130117
130254
|
return CompletionSource.ThisProperty;
|
|
130118
130255
|
}
|
|
130119
130256
|
}
|
|
130120
|
-
function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
|
|
130257
|
+
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) {
|
|
130121
130258
|
var _a;
|
|
130122
130259
|
var start = ts.timestamp();
|
|
130123
130260
|
var variableDeclaration = getVariableDeclaration(location);
|
|
@@ -130138,7 +130275,7 @@ var ts;
|
|
|
130138
130275
|
var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
|
|
130139
130276
|
var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
|
|
130140
130277
|
var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
|
|
130141
|
-
var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind, formatContext);
|
|
130278
|
+
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);
|
|
130142
130279
|
if (!entry) {
|
|
130143
130280
|
continue;
|
|
130144
130281
|
}
|
|
@@ -130732,6 +130869,7 @@ var ts;
|
|
|
130732
130869
|
symbolToSortTextIdMap: symbolToSortTextIdMap,
|
|
130733
130870
|
isTypeOnlyLocation: isTypeOnlyLocation,
|
|
130734
130871
|
isJsxIdentifierExpected: isJsxIdentifierExpected,
|
|
130872
|
+
isRightOfOpenTag: isRightOfOpenTag,
|
|
130735
130873
|
importCompletionNode: importCompletionNode,
|
|
130736
130874
|
hasUnresolvedAutoImports: hasUnresolvedAutoImports,
|
|
130737
130875
|
};
|
|
@@ -146841,20 +146979,31 @@ var ts;
|
|
|
146841
146979
|
codefix.registerCodeFix({
|
|
146842
146980
|
errorCodes: errorCodes,
|
|
146843
146981
|
getCodeActions: function getCodeActionsToAddConvertToUnknownForNonOverlappingTypes(context) {
|
|
146844
|
-
var
|
|
146982
|
+
var assertion = getAssertion(context.sourceFile, context.span.start);
|
|
146983
|
+
if (assertion === undefined)
|
|
146984
|
+
return undefined;
|
|
146985
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return makeChange(t, context.sourceFile, assertion); });
|
|
146845
146986
|
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)];
|
|
146846
146987
|
},
|
|
146847
146988
|
fixIds: [fixId],
|
|
146848
|
-
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
146989
|
+
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
146990
|
+
var assertion = getAssertion(diag.file, diag.start);
|
|
146991
|
+
if (assertion) {
|
|
146992
|
+
makeChange(changes, diag.file, assertion);
|
|
146993
|
+
}
|
|
146994
|
+
}); },
|
|
146849
146995
|
});
|
|
146850
|
-
function makeChange(changeTracker, sourceFile,
|
|
146851
|
-
var token = ts.getTokenAtPosition(sourceFile, pos);
|
|
146852
|
-
var assertion = ts.Debug.checkDefined(ts.findAncestor(token, function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); }), "Expected to find an assertion expression");
|
|
146996
|
+
function makeChange(changeTracker, sourceFile, assertion) {
|
|
146853
146997
|
var replacement = ts.isAsExpression(assertion)
|
|
146854
146998
|
? ts.factory.createAsExpression(assertion.expression, ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */))
|
|
146855
146999
|
: ts.factory.createTypeAssertion(ts.factory.createKeywordTypeNode(154 /* UnknownKeyword */), assertion.expression);
|
|
146856
147000
|
changeTracker.replaceNode(sourceFile, assertion.expression, replacement);
|
|
146857
147001
|
}
|
|
147002
|
+
function getAssertion(sourceFile, pos) {
|
|
147003
|
+
if (ts.isInJSFile(sourceFile))
|
|
147004
|
+
return undefined;
|
|
147005
|
+
return ts.findAncestor(ts.getTokenAtPosition(sourceFile, pos), function (n) { return ts.isAsExpression(n) || ts.isTypeAssertionExpression(n); });
|
|
147006
|
+
}
|
|
146858
147007
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
146859
147008
|
})(ts || (ts = {}));
|
|
146860
147009
|
/* @internal */
|
|
@@ -149972,10 +150121,15 @@ var ts;
|
|
|
149972
150121
|
if (a.kind !== 0 /* UseNamespace */ && b.kind !== 0 /* UseNamespace */) {
|
|
149973
150122
|
return ts.compareBooleans(allowsImportingSpecifier(b.moduleSpecifier), allowsImportingSpecifier(a.moduleSpecifier))
|
|
149974
150123
|
|| compareNodeCoreModuleSpecifiers(a.moduleSpecifier, b.moduleSpecifier, importingFile, program)
|
|
150124
|
+
|| ts.compareBooleans(isOnlyDotsAndSlashes(a.moduleSpecifier), isOnlyDotsAndSlashes(b.moduleSpecifier))
|
|
149975
150125
|
|| ts.compareNumberOfDirectorySeparators(a.moduleSpecifier, b.moduleSpecifier);
|
|
149976
150126
|
}
|
|
149977
150127
|
return 0 /* EqualTo */;
|
|
149978
150128
|
}
|
|
150129
|
+
var notDotOrSlashPattern = /[^.\/]/;
|
|
150130
|
+
function isOnlyDotsAndSlashes(path) {
|
|
150131
|
+
return !notDotOrSlashPattern.test(path);
|
|
150132
|
+
}
|
|
149979
150133
|
function compareNodeCoreModuleSpecifiers(a, b, importingFile, program) {
|
|
149980
150134
|
if (ts.startsWith(a, "node:") && !ts.startsWith(b, "node:"))
|
|
149981
150135
|
return ts.shouldUseUriStyleNodeCoreModules(importingFile, program) ? -1 /* LessThan */ : 1 /* GreaterThan */;
|