typescript 4.5.0-dev.20211029 → 4.5.1-rc

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/tsserver.js CHANGED
@@ -22,7 +22,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
22
22
  ar[i] = from[i];
23
23
  }
24
24
  }
25
- return to.concat(ar || from);
25
+ return to.concat(ar || Array.prototype.slice.call(from));
26
26
  };
27
27
  var __assign = (this && this.__assign) || function () {
28
28
  __assign = Object.assign || function(t) {
@@ -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.20211029";
103
+ ts.version = ts.versionMajorMinor + ".1-rc";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -5126,7 +5126,7 @@ var ts;
5126
5126
  (function (ModuleResolutionKind) {
5127
5127
  ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
5128
5128
  ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
5129
- // Starting with node12, node's module resolver has significant departures from tranditional cjs resolution
5129
+ // Starting with node12, node's module resolver has significant departures from traditional cjs resolution
5130
5130
  // to better support ecmascript modules and their use within node - more features are still being added, so
5131
5131
  // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12`
5132
5132
  // version-anchored resolution target
@@ -8704,6 +8704,8 @@ var ts;
8704
8704
  Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext: diag(2821, ts.DiagnosticCategory.Error, "Import_assertions_are_only_supported_when_the_module_option_is_set_to_esnext_2821", "Import assertions are only supported when the '--module' option is set to 'esnext'."),
8705
8705
  Import_assertions_cannot_be_used_with_type_only_imports_or_exports: diag(2822, ts.DiagnosticCategory.Error, "Import_assertions_cannot_be_used_with_type_only_imports_or_exports_2822", "Import assertions cannot be used with type-only imports or exports."),
8706
8706
  Cannot_find_namespace_0_Did_you_mean_1: diag(2833, ts.DiagnosticCategory.Error, "Cannot_find_namespace_0_Did_you_mean_1_2833", "Cannot find namespace '{0}'. Did you mean '{1}'?"),
8707
+ Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path: diag(2834, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2834", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Consider adding an extension to the import path."),
8708
+ Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0: diag(2835, ts.DiagnosticCategory.Error, "Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_n_2835", "Relative import paths need explicit file extensions in EcmaScript imports when '--moduleResolution' is 'node12' or 'nodenext'. Did you mean '{0}'?"),
8707
8709
  Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
8708
8710
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
8709
8711
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -8810,6 +8812,7 @@ var ts;
8810
8812
  This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class: diag(4121, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_4121", "This member cannot have a JSDoc comment with an '@override' tag because its containing class '{0}' does not extend another class."),
8811
8813
  This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0: diag(4122, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4122", "This member cannot have a JSDoc comment with an '@override' tag because it is not declared in the base class '{0}'."),
8812
8814
  This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1: diag(4123, ts.DiagnosticCategory.Error, "This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base__4123", "This member cannot have a JSDoc comment with an 'override' tag because it is not declared in the base class '{0}'. Did you mean '{1}'?"),
8815
+ Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(4124, ts.DiagnosticCategory.Error, "Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_w_4124", "Compiler option '{0}' of value '{1}' is unstable. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
8813
8816
  The_current_host_does_not_support_the_0_option: diag(5001, ts.DiagnosticCategory.Error, "The_current_host_does_not_support_the_0_option_5001", "The current host does not support the '{0}' option."),
8814
8817
  Cannot_find_the_common_subdirectory_path_for_the_input_files: diag(5009, ts.DiagnosticCategory.Error, "Cannot_find_the_common_subdirectory_path_for_the_input_files_5009", "Cannot find the common subdirectory path for the input files."),
8815
8818
  File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0: diag(5010, ts.DiagnosticCategory.Error, "File_specification_cannot_end_in_a_recursive_directory_wildcard_Asterisk_Asterisk_Colon_0_5010", "File specification cannot end in a recursive directory wildcard ('**'): '{0}'."),
@@ -9467,6 +9470,7 @@ var ts;
9467
9470
  Remove_unused_destructuring_declaration: diag(90039, ts.DiagnosticCategory.Message, "Remove_unused_destructuring_declaration_90039", "Remove unused destructuring declaration"),
9468
9471
  Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
9469
9472
  Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
9473
+ Includes_imports_of_types_referenced_by_0: diag(90054, ts.DiagnosticCategory.Message, "Includes_imports_of_types_referenced_by_0_90054", "Includes imports of types referenced by '{0}'"),
9470
9474
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9471
9475
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9472
9476
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -47368,6 +47372,21 @@ var ts;
47368
47372
  var enumRelation = new ts.Map();
47369
47373
  var builtinGlobals = ts.createSymbolTable();
47370
47374
  builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
47375
+ // Extensions suggested for path imports when module resolution is node12 or higher.
47376
+ // The first element of each tuple is the extension a file has.
47377
+ // The second element of each tuple is the extension that should be used in a path import.
47378
+ // e.g. if we want to import file `foo.mts`, we should write `import {} from "./foo.mjs".
47379
+ var suggestedExtensions = [
47380
+ [".mts", ".mjs"],
47381
+ [".ts", ".js"],
47382
+ [".cts", ".cjs"],
47383
+ [".mjs", ".mjs"],
47384
+ [".js", ".js"],
47385
+ [".cjs", ".cjs"],
47386
+ [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"],
47387
+ [".jsx", ".jsx"],
47388
+ [".json", ".json"],
47389
+ ];
47371
47390
  initializeTypeChecker();
47372
47391
  return checker;
47373
47392
  function getJsxNamespace(location) {
@@ -49583,7 +49602,7 @@ var ts;
49583
49602
  : undefined;
49584
49603
  }
49585
49604
  function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
49586
- var _a, _b, _c, _d, _e, _f;
49605
+ var _a, _b, _c, _d, _e, _f, _g;
49587
49606
  if (isForAugmentation === void 0) { isForAugmentation = false; }
49588
49607
  if (ts.startsWith(moduleReference, "@types/")) {
49589
49608
  var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
@@ -49604,7 +49623,7 @@ var ts;
49604
49623
  ((_e = (ts.isModuleDeclaration(location) ? location : location.parent && ts.isModuleDeclaration(location.parent) && location.parent.name === location ? location.parent : undefined)) === null || _e === void 0 ? void 0 : _e.name) ||
49605
49624
  ((_f = (ts.isLiteralImportTypeNode(location) ? location : undefined)) === null || _f === void 0 ? void 0 : _f.argument.literal);
49606
49625
  var mode = contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
49607
- var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode); // TODO: GH#18217
49626
+ var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode);
49608
49627
  var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
49609
49628
  var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
49610
49629
  if (sourceFile) {
@@ -49670,6 +49689,10 @@ var ts;
49670
49689
  }
49671
49690
  else {
49672
49691
  var tsExtension = ts.tryExtractTSExtension(moduleReference);
49692
+ var isExtensionlessRelativePathImport = ts.pathIsRelative(moduleReference) && !ts.hasExtension(moduleReference);
49693
+ var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions);
49694
+ var resolutionIsNode12OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node12 ||
49695
+ moduleResolutionKind === ts.ModuleResolutionKind.NodeNext;
49673
49696
  if (tsExtension) {
49674
49697
  var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
49675
49698
  var importSourceWithoutExtension = ts.removeExtension(moduleReference, tsExtension);
@@ -49689,6 +49712,19 @@ var ts;
49689
49712
  ts.hasJsonModuleEmitEnabled(compilerOptions)) {
49690
49713
  error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
49691
49714
  }
49715
+ else if (mode === ts.ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) {
49716
+ var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path));
49717
+ var suggestedExt = (_g = suggestedExtensions.find(function (_a) {
49718
+ var actualExt = _a[0], _importExt = _a[1];
49719
+ return host.fileExists(absoluteRef_1 + actualExt);
49720
+ })) === null || _g === void 0 ? void 0 : _g[1];
49721
+ if (suggestedExt) {
49722
+ error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Did_you_mean_0, moduleReference + suggestedExt);
49723
+ }
49724
+ else {
49725
+ error(errorNode, ts.Diagnostics.Relative_import_paths_need_explicit_file_extensions_in_EcmaScript_imports_when_moduleResolution_is_node12_or_nodenext_Consider_adding_an_extension_to_the_import_path);
49726
+ }
49727
+ }
49692
49728
  else {
49693
49729
  error(errorNode, moduleNotFoundError, moduleReference);
49694
49730
  }
@@ -61601,7 +61637,8 @@ var ts;
61601
61637
  if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
61602
61638
  if (!type.declaration.nameType) {
61603
61639
  var constraint = void 0;
61604
- if (isArrayType(t) || (t.flags & 1 /* Any */) && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
61640
+ if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
61641
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
61605
61642
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
61606
61643
  }
61607
61644
  if (isGenericTupleType(t)) {
@@ -94904,11 +94941,11 @@ var ts;
94904
94941
  currentFileState.filenameDeclaration = declaration;
94905
94942
  return currentFileState.filenameDeclaration.name;
94906
94943
  }
94907
- function getJsxFactoryCalleePrimitive(childrenLength) {
94908
- return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : childrenLength > 1 ? "jsxs" : "jsx";
94944
+ function getJsxFactoryCalleePrimitive(isStaticChildren) {
94945
+ return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx";
94909
94946
  }
94910
- function getJsxFactoryCallee(childrenLength) {
94911
- var type = getJsxFactoryCalleePrimitive(childrenLength);
94947
+ function getJsxFactoryCallee(isStaticChildren) {
94948
+ var type = getJsxFactoryCalleePrimitive(isStaticChildren);
94912
94949
  return getImplicitImportForName(type);
94913
94950
  }
94914
94951
  function getImplicitJsxFragmentReference() {
@@ -95060,7 +95097,7 @@ var ts;
95060
95097
  }
95061
95098
  function convertJsxChildrenToChildrenPropAssignment(children) {
95062
95099
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95063
- if (ts.length(nonWhitespaceChildren) === 1) {
95100
+ if (ts.length(nonWhitespaceChildren) === 1 && !nonWhitespaceChildren[0].dotDotDotToken) {
95064
95101
  var result_12 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
95065
95102
  return result_12 && factory.createPropertyAssignment("children", result_12);
95066
95103
  }
@@ -95074,15 +95111,18 @@ var ts;
95074
95111
  var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties;
95075
95112
  var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs, childrenProp) :
95076
95113
  factory.createObjectLiteralExpression(childrenProp ? [childrenProp] : ts.emptyArray); // When there are no attributes, React wants {}
95077
- return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, ts.length(ts.getSemanticJsxChildren(children || ts.emptyArray)), isChild, location);
95114
+ return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, children || ts.emptyArray, isChild, location);
95078
95115
  }
95079
- function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, childrenLength, isChild, location) {
95116
+ function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, children, isChild, location) {
95117
+ var _a;
95118
+ var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95119
+ var isStaticChildren = ts.length(nonWhitespaceChildren) > 1 || !!((_a = nonWhitespaceChildren[0]) === null || _a === void 0 ? void 0 : _a.dotDotDotToken);
95080
95120
  var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)];
95081
95121
  if (compilerOptions.jsx === 5 /* ReactJSXDev */) {
95082
95122
  var originalFile = ts.getOriginalNode(currentSourceFile);
95083
95123
  if (originalFile && ts.isSourceFile(originalFile)) {
95084
95124
  // isStaticChildren development flag
95085
- args.push(childrenLength > 1 ? factory.createTrue() : factory.createFalse());
95125
+ args.push(isStaticChildren ? factory.createTrue() : factory.createFalse());
95086
95126
  // __source development flag
95087
95127
  var lineCol = ts.getLineAndCharacterOfPosition(originalFile, location.pos);
95088
95128
  args.push(factory.createObjectLiteralExpression([
@@ -95094,7 +95134,7 @@ var ts;
95094
95134
  args.push(factory.createThis());
95095
95135
  }
95096
95136
  }
95097
- var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(childrenLength), /*typeArguments*/ undefined, args), location);
95137
+ var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(isStaticChildren), /*typeArguments*/ undefined, args), location);
95098
95138
  if (isChild) {
95099
95139
  ts.startOnNewLine(element);
95100
95140
  }
@@ -95124,7 +95164,7 @@ var ts;
95124
95164
  }
95125
95165
  }
95126
95166
  return visitJsxOpeningLikeElementOrFragmentJSX(getImplicitJsxFragmentReference(), childrenProps || factory.createObjectLiteralExpression([]),
95127
- /*keyAttr*/ undefined, ts.length(ts.getSemanticJsxChildren(children)), isChild, location);
95167
+ /*keyAttr*/ undefined, children, isChild, location);
95128
95168
  }
95129
95169
  function visitJsxOpeningFragmentCreateElement(node, children, isChild, location) {
95130
95170
  var element = ts.createExpressionForJsxFragment(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), context.getEmitResolver().getJsxFragmentFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217
@@ -114200,8 +114240,8 @@ var ts;
114200
114240
  var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
114201
114241
  var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
114202
114242
  // ensure that types resolutions are still correct
114203
- var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
114204
- if (typeReferenceEesolutionsChanged) {
114243
+ var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
114244
+ if (typeReferenceResolutionsChanged) {
114205
114245
  structureIsReused = 1 /* SafeModules */;
114206
114246
  newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
114207
114247
  }
@@ -115489,6 +115529,21 @@ var ts;
115489
115529
  return resolvedRef;
115490
115530
  }
115491
115531
  function verifyCompilerOptions() {
115532
+ var isNightly = ts.stringContains(ts.version, "-dev");
115533
+ if (!isNightly) {
115534
+ if (ts.getEmitModuleKind(options) === ts.ModuleKind.Node12) {
115535
+ createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "node12");
115536
+ }
115537
+ else if (ts.getEmitModuleKind(options) === ts.ModuleKind.NodeNext) {
115538
+ createOptionValueDiagnostic("module", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "module", "nodenext");
115539
+ }
115540
+ else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12) {
115541
+ createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "node12");
115542
+ }
115543
+ else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
115544
+ createOptionValueDiagnostic("moduleResolution", ts.Diagnostics.Compiler_option_0_of_value_1_is_unstable_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next, "moduleResolution", "nodenext");
115545
+ }
115546
+ }
115492
115547
  if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
115493
115548
  createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
115494
115549
  }
@@ -115967,8 +116022,8 @@ var ts;
115967
116022
  function createDiagnosticForOptionName(message, option1, option2, option3) {
115968
116023
  createDiagnosticForOption(/*onKey*/ true, option1, option2, message, option1, option2, option3);
115969
116024
  }
115970
- function createOptionValueDiagnostic(option1, message, arg0) {
115971
- createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0);
116025
+ function createOptionValueDiagnostic(option1, message, arg0, arg1) {
116026
+ createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0, arg1);
115972
116027
  }
115973
116028
  function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) {
115974
116029
  var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; });
@@ -118212,6 +118267,9 @@ var ts;
118212
118267
  else {
118213
118268
  resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
118214
118269
  perDirectoryResolution.set(name, mode, resolution);
118270
+ if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
118271
+ resolutionHost.onDiscoveredSymlink();
118272
+ }
118215
118273
  }
118216
118274
  resolutionsInFile.set(name, mode, resolution);
118217
118275
  watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
@@ -118680,6 +118738,11 @@ var ts;
118680
118738
  }
118681
118739
  }
118682
118740
  ts.createResolutionCache = createResolutionCache;
118741
+ function resolutionIsSymlink(resolution) {
118742
+ var _a, _b;
118743
+ return !!(((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.originalPath) ||
118744
+ ((_b = resolution.resolvedTypeReferenceDirective) === null || _b === void 0 ? void 0 : _b.originalPath));
118745
+ }
118683
118746
  })(ts || (ts = {}));
118684
118747
  // Used by importFixes, getEditsForFileRename, and declaration emit to synthesize import module specifiers.
118685
118748
  /* @internal */
@@ -125738,6 +125801,12 @@ var ts;
125738
125801
  return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */;
125739
125802
  }
125740
125803
  ts.getNewLineKind = getNewLineKind;
125804
+ function diagnosticToString(diag) {
125805
+ return ts.isArray(diag)
125806
+ ? ts.formatStringFromArgs(ts.getLocaleSpecificMessage(diag[0]), diag.slice(1))
125807
+ : ts.getLocaleSpecificMessage(diag);
125808
+ }
125809
+ ts.diagnosticToString = diagnosticToString;
125741
125810
  // #endregion
125742
125811
  })(ts || (ts = {}));
125743
125812
  /*@internal*/
@@ -128084,6 +128153,8 @@ var ts;
128084
128153
  (function (CompletionSource) {
128085
128154
  /** Completions that require `this.` insertion text */
128086
128155
  CompletionSource["ThisProperty"] = "ThisProperty/";
128156
+ /** Auto-import that comes attached to a class member snippet */
128157
+ CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
128087
128158
  })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
128088
128159
  var SymbolOriginInfoKind;
128089
128160
  (function (SymbolOriginInfoKind) {
@@ -128446,6 +128517,7 @@ var ts;
128446
128517
  var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
128447
128518
  var data;
128448
128519
  var isSnippet;
128520
+ var source = getSourceFromOrigin(origin);
128449
128521
  var sourceDisplay;
128450
128522
  var hasAction;
128451
128523
  var typeChecker = program.getTypeChecker();
@@ -128503,7 +128575,12 @@ var ts;
128503
128575
  preferences.includeCompletionsWithInsertText &&
128504
128576
  completionKind === 3 /* MemberLike */ &&
128505
128577
  isClassLikeMemberCompletion(symbol, location)) {
128506
- (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet);
128578
+ var importAdder = void 0;
128579
+ (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder);
128580
+ if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
128581
+ hasAction = true;
128582
+ source = CompletionSource.ClassMemberSnippet;
128583
+ }
128507
128584
  }
128508
128585
  var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location);
128509
128586
  if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
@@ -128550,7 +128627,7 @@ var ts;
128550
128627
  kind: kind,
128551
128628
  kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol),
128552
128629
  sortText: sortText,
128553
- source: getSourceFromOrigin(origin),
128630
+ source: source,
128554
128631
  hasAction: hasAction ? true : undefined,
128555
128632
  isRecommended: isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker) || undefined,
128556
128633
  insertText: insertText,
@@ -128619,15 +128696,14 @@ var ts;
128619
128696
  });
128620
128697
  var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
128621
128698
  var body;
128622
- var tabstopStart = 1;
128623
128699
  if (preferences.includeCompletionsWithSnippetText) {
128624
128700
  isSnippet = true;
128625
- // We are adding a final tabstop (i.e. $0) in the body of the suggested member, if it has one.
128701
+ // We are adding a tabstop (i.e. `$0`) in the body of the suggested member,
128702
+ // if it has one, so that the cursor ends up in the body once the completion is inserted.
128626
128703
  // Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
128627
- var emptyStatement1 = ts.factory.createExpressionStatement(ts.factory.createIdentifier(""));
128628
- ts.setSnippetElement(emptyStatement1, { kind: 0 /* TabStop */, order: 1 });
128629
- tabstopStart = 2;
128630
- body = ts.factory.createBlock([emptyStatement1], /* multiline */ true);
128704
+ var emptyStatement = ts.factory.createExpressionStatement(ts.factory.createIdentifier(""));
128705
+ ts.setSnippetElement(emptyStatement, { kind: 0 /* TabStop */, order: 0 });
128706
+ body = ts.factory.createBlock([emptyStatement], /* multiline */ true);
128631
128707
  }
128632
128708
  else {
128633
128709
  body = ts.factory.createBlock([], /* multiline */ true);
@@ -128673,12 +128749,9 @@ var ts;
128673
128749
  completionNodes.push(node);
128674
128750
  }, body, isAbstract);
128675
128751
  if (completionNodes.length) {
128676
- if (preferences.includeCompletionsWithSnippetText) {
128677
- addSnippets(completionNodes, tabstopStart);
128678
- }
128679
128752
  insertText = printer.printSnippetList(1 /* MultiLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
128680
128753
  }
128681
- return { insertText: insertText, isSnippet: isSnippet };
128754
+ return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder };
128682
128755
  }
128683
128756
  function getPresentModifiers(contextToken) {
128684
128757
  var modifiers = 0 /* None */;
@@ -128719,33 +128792,6 @@ var ts;
128719
128792
  }
128720
128793
  return undefined;
128721
128794
  }
128722
- function addSnippets(nodes, orderStart) {
128723
- var order = orderStart;
128724
- for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
128725
- var node = nodes_1[_i];
128726
- addSnippetsWorker(node, /*parent*/ undefined);
128727
- }
128728
- function addSnippetsWorker(node, parent) {
128729
- if (ts.isVariableLike(node) && node.kind === 163 /* Parameter */) {
128730
- // Placeholder
128731
- ts.setSnippetElement(node.name, { kind: 1 /* Placeholder */, order: order });
128732
- order += 1;
128733
- if (node.type) {
128734
- ts.setSnippetElement(node.type, { kind: 1 /* Placeholder */, order: order });
128735
- order += 1;
128736
- }
128737
- }
128738
- else if (ts.isTypeNode(node) && parent && ts.isFunctionLikeDeclaration(parent)) {
128739
- ts.setSnippetElement(node, { kind: 1 /* Placeholder */, order: order });
128740
- order += 1;
128741
- }
128742
- else if (ts.isTypeParameterDeclaration(node) && parent && ts.isFunctionLikeDeclaration(parent)) {
128743
- ts.setSnippetElement(node, { kind: 1 /* Placeholder */, order: order });
128744
- order += 1;
128745
- }
128746
- ts.forEachChild(node, function (child) { return addSnippetsWorker(child, node); });
128747
- }
128748
- }
128749
128795
  function createSnippetPrinter(printerOptions) {
128750
128796
  var printer = ts.createPrinter(printerOptions);
128751
128797
  var baseWriter = ts.createTextWriter(ts.getNewLineCharacter(printerOptions));
@@ -128967,11 +129013,13 @@ var ts;
128967
129013
  if (entryId.data) {
128968
129014
  var autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host);
128969
129015
  if (autoImport) {
129016
+ var _a = getRelevantTokens(position, sourceFile), contextToken_1 = _a.contextToken, previousToken_1 = _a.previousToken;
128970
129017
  return {
128971
129018
  type: "symbol",
128972
129019
  symbol: autoImport.symbol,
128973
129020
  location: ts.getTouchingPropertyName(sourceFile, position),
128974
- previousToken: ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined),
129021
+ previousToken: previousToken_1,
129022
+ contextToken: contextToken_1,
128975
129023
  isJsxInitializer: false,
128976
129024
  isTypeOnlyLocation: false,
128977
129025
  origin: autoImport.origin,
@@ -128986,7 +129034,7 @@ var ts;
128986
129034
  if (completionData.kind !== 0 /* Data */) {
128987
129035
  return { type: "request", request: completionData };
128988
129036
  }
128989
- var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation;
129037
+ var symbols = completionData.symbols, literals = completionData.literals, location = completionData.location, completionKind = completionData.completionKind, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, contextToken = completionData.contextToken, previousToken = completionData.previousToken, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation;
128990
129038
  var literal = ts.find(literals, function (l) { return completionNameForLiteral(sourceFile, preferences, l) === entryId.name; });
128991
129039
  if (literal !== undefined)
128992
129040
  return { type: "literal", literal: literal };
@@ -128997,15 +129045,15 @@ var ts;
128997
129045
  return ts.firstDefined(symbols, function (symbol, index) {
128998
129046
  var origin = symbolToOriginInfoMap[index];
128999
129047
  var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
129000
- return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source
129001
- ? { type: "symbol", symbol: symbol, location: location, origin: origin, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
129048
+ return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ || getSourceFromOrigin(origin) === entryId.source)
129049
+ ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
129002
129050
  : undefined;
129003
129051
  }) || { type: "none" };
129004
129052
  }
129005
129053
  function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) {
129006
129054
  var typeChecker = program.getTypeChecker();
129007
129055
  var compilerOptions = program.getCompilerOptions();
129008
- var name = entryId.name;
129056
+ var name = entryId.name, source = entryId.source, data = entryId.data;
129009
129057
  var contextToken = ts.findPrecedingToken(position, sourceFile);
129010
129058
  if (ts.isInString(sourceFile, position, contextToken)) {
129011
129059
  return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken, preferences);
@@ -129029,8 +129077,8 @@ var ts;
129029
129077
  }
129030
129078
  }
129031
129079
  case "symbol": {
129032
- var symbol = symbolCompletion.symbol, location = symbolCompletion.location, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken;
129033
- var _a = getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, entryId.data), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay;
129080
+ var symbol = symbolCompletion.symbol, location = symbolCompletion.location, contextToken_2 = symbolCompletion.contextToken, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken;
129081
+ var _a = getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken_2, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay;
129034
129082
  return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217
129035
129083
  }
129036
129084
  case "literal": {
@@ -129059,14 +129107,27 @@ var ts;
129059
129107
  return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source, sourceDisplay: source };
129060
129108
  }
129061
129109
  Completions.createCompletionDetails = createCompletionDetails;
129062
- function getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data) {
129110
+ function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source) {
129063
129111
  if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
129064
- var _a = getRelevantTokens(position, sourceFile), contextToken = _a.contextToken, previousToken_1 = _a.previousToken;
129065
- if (previousToken_1 && getImportStatementCompletionInfo(contextToken || previousToken_1).replacementNode) {
129112
+ var _a = getRelevantTokens(position, sourceFile), contextToken_3 = _a.contextToken, previousToken_2 = _a.previousToken;
129113
+ if (previousToken_2 && getImportStatementCompletionInfo(contextToken_3 || previousToken_2).replacementNode) {
129066
129114
  // Import statement completion: 'import c|'
129067
129115
  return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
129068
129116
  }
129069
129117
  }
129118
+ if (source === CompletionSource.ClassMemberSnippet) {
129119
+ var importAdder = getEntryForMemberCompletion(host, program, compilerOptions, preferences, name, symbol, location, contextToken).importAdder;
129120
+ if (importAdder) {
129121
+ var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
129122
+ return {
129123
+ sourceDisplay: undefined,
129124
+ codeActions: [{
129125
+ changes: changes,
129126
+ description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
129127
+ }],
129128
+ };
129129
+ }
129130
+ }
129070
129131
  if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
129071
129132
  return { codeActions: undefined, sourceDisplay: undefined };
129072
129133
  }
@@ -144266,8 +144327,8 @@ var ts;
144266
144327
  ChangeTracker.prototype.deleteNodes = function (sourceFile, nodes, options, hasTrailingComment) {
144267
144328
  if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
144268
144329
  // When deleting multiple nodes we need to track if the end position is including multiline trailing comments.
144269
- for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
144270
- var node = nodes_2[_i];
144330
+ for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
144331
+ var node = nodes_1[_i];
144271
144332
  var pos = getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment);
144272
144333
  var end = getAdjustedEndPosition(sourceFile, node, options);
144273
144334
  this.deleteRange(sourceFile, { pos: pos, end: end });
@@ -145372,21 +145433,16 @@ var ts;
145372
145433
  (function (codefix) {
145373
145434
  var errorCodeToFixes = ts.createMultiMap();
145374
145435
  var fixIdToRegistration = new ts.Map();
145375
- function diagnosticToString(diag) {
145376
- return ts.isArray(diag)
145377
- ? ts.formatStringFromArgs(ts.getLocaleSpecificMessage(diag[0]), diag.slice(1))
145378
- : ts.getLocaleSpecificMessage(diag);
145379
- }
145380
145436
  function createCodeFixActionWithoutFixAll(fixName, changes, description) {
145381
- return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, /*fixId*/ undefined, /*fixAllDescription*/ undefined);
145437
+ return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, /*fixId*/ undefined, /*fixAllDescription*/ undefined);
145382
145438
  }
145383
145439
  codefix.createCodeFixActionWithoutFixAll = createCodeFixActionWithoutFixAll;
145384
145440
  function createCodeFixAction(fixName, changes, description, fixId, fixAllDescription, command) {
145385
- return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, diagnosticToString(fixAllDescription), command);
145441
+ return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, fixId, ts.diagnosticToString(fixAllDescription), command);
145386
145442
  }
145387
145443
  codefix.createCodeFixAction = createCodeFixAction;
145388
145444
  function createCodeFixActionMaybeFixAll(fixName, changes, description, fixId, fixAllDescription, command) {
145389
- return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, fixAllDescription && diagnosticToString(fixAllDescription), command);
145445
+ return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, fixId, fixAllDescription && ts.diagnosticToString(fixAllDescription), command);
145390
145446
  }
145391
145447
  codefix.createCodeFixActionMaybeFixAll = createCodeFixActionMaybeFixAll;
145392
145448
  function createCodeFixActionWorker(fixName, description, changes, fixId, fixAllDescription, command) {
@@ -148147,7 +148203,7 @@ var ts;
148147
148203
  var addToExisting = new ts.Map();
148148
148204
  /** Use `getNewImportEntry` for access */
148149
148205
  var newImports = new ts.Map();
148150
- return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes };
148206
+ return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes, hasFixes: hasFixes };
148151
148207
  function addImportFromDiagnostic(diagnostic, context) {
148152
148208
  var info = getFixesInfo(context, diagnostic.code, diagnostic.start, useAutoImportProvider);
148153
148209
  if (!info || !info.fixes.length)
@@ -148298,6 +148354,9 @@ var ts;
148298
148354
  ts.insertImports(changeTracker, sourceFile, newDeclarations, /*blankLineBetween*/ true);
148299
148355
  }
148300
148356
  }
148357
+ function hasFixes() {
148358
+ return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0;
148359
+ }
148301
148360
  }
148302
148361
  // Sorted with the preferred fix coming first.
148303
148362
  var ImportFixKind;
@@ -158819,8 +158878,8 @@ var ts;
158819
158878
  var list = createNode(346 /* SyntaxList */, nodes.pos, nodes.end, parent);
158820
158879
  list._children = [];
158821
158880
  var pos = nodes.pos;
158822
- for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) {
158823
- var node = nodes_3[_i];
158881
+ for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
158882
+ var node = nodes_2[_i];
158824
158883
  addSyntheticNodes(list._children, pos, node.pos, parent);
158825
158884
  list._children.push(node);
158826
158885
  pos = node.end;
@@ -164844,6 +164903,10 @@ var ts;
164844
164903
  this.hasAddedOrRemovedSymlinks = true;
164845
164904
  }
164846
164905
  };
164906
+ /* @internal */
164907
+ Project.prototype.onDiscoveredSymlink = function () {
164908
+ this.hasAddedOrRemovedSymlinks = true;
164909
+ };
164847
164910
  /**
164848
164911
  * Updates set of files that contribute to this project
164849
164912
  * @returns: true if set of files in the project stays the same and false - otherwise.