typescript 4.5.0-dev.20211029 → 4.6.0-dev.20211102

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/typescript.js CHANGED
@@ -290,11 +290,11 @@ var ts;
290
290
  (function (ts) {
291
291
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
292
292
  // If changing the text in this section, be sure to test `configurePrerelease` too.
293
- ts.versionMajorMinor = "4.5";
293
+ ts.versionMajorMinor = "4.6";
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.20211029";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20211102";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -5320,7 +5320,7 @@ var ts;
5320
5320
  (function (ModuleResolutionKind) {
5321
5321
  ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
5322
5322
  ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
5323
- // Starting with node12, node's module resolver has significant departures from tranditional cjs resolution
5323
+ // Starting with node12, node's module resolver has significant departures from traditional cjs resolution
5324
5324
  // to better support ecmascript modules and their use within node - more features are still being added, so
5325
5325
  // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12`
5326
5326
  // version-anchored resolution target
@@ -8898,6 +8898,8 @@ var ts;
8898
8898
  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'."),
8899
8899
  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."),
8900
8900
  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}'?"),
8901
+ 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."),
8902
+ 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}'?"),
8901
8903
  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}'."),
8902
8904
  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}'."),
8903
8905
  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}'."),
@@ -9004,6 +9006,7 @@ var ts;
9004
9006
  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."),
9005
9007
  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}'."),
9006
9008
  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}'?"),
9009
+ 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'."),
9007
9010
  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."),
9008
9011
  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."),
9009
9012
  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}'."),
@@ -9661,6 +9664,7 @@ var ts;
9661
9664
  Remove_unused_destructuring_declaration: diag(90039, ts.DiagnosticCategory.Message, "Remove_unused_destructuring_declaration_90039", "Remove unused destructuring declaration"),
9662
9665
  Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
9663
9666
  Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
9667
+ 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}'"),
9664
9668
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9665
9669
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9666
9670
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -47562,6 +47566,21 @@ var ts;
47562
47566
  var enumRelation = new ts.Map();
47563
47567
  var builtinGlobals = ts.createSymbolTable();
47564
47568
  builtinGlobals.set(undefinedSymbol.escapedName, undefinedSymbol);
47569
+ // Extensions suggested for path imports when module resolution is node12 or higher.
47570
+ // The first element of each tuple is the extension a file has.
47571
+ // The second element of each tuple is the extension that should be used in a path import.
47572
+ // e.g. if we want to import file `foo.mts`, we should write `import {} from "./foo.mjs".
47573
+ var suggestedExtensions = [
47574
+ [".mts", ".mjs"],
47575
+ [".ts", ".js"],
47576
+ [".cts", ".cjs"],
47577
+ [".mjs", ".mjs"],
47578
+ [".js", ".js"],
47579
+ [".cjs", ".cjs"],
47580
+ [".tsx", compilerOptions.jsx === 1 /* Preserve */ ? ".jsx" : ".js"],
47581
+ [".jsx", ".jsx"],
47582
+ [".json", ".json"],
47583
+ ];
47565
47584
  initializeTypeChecker();
47566
47585
  return checker;
47567
47586
  function getJsxNamespace(location) {
@@ -49777,7 +49796,7 @@ var ts;
49777
49796
  : undefined;
49778
49797
  }
49779
49798
  function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
49780
- var _a, _b, _c, _d, _e, _f;
49799
+ var _a, _b, _c, _d, _e, _f, _g;
49781
49800
  if (isForAugmentation === void 0) { isForAugmentation = false; }
49782
49801
  if (ts.startsWith(moduleReference, "@types/")) {
49783
49802
  var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
@@ -49798,7 +49817,7 @@ var ts;
49798
49817
  ((_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) ||
49799
49818
  ((_f = (ts.isLiteralImportTypeNode(location) ? location : undefined)) === null || _f === void 0 ? void 0 : _f.argument.literal);
49800
49819
  var mode = contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
49801
- var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode); // TODO: GH#18217
49820
+ var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode);
49802
49821
  var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
49803
49822
  var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
49804
49823
  if (sourceFile) {
@@ -49864,6 +49883,10 @@ var ts;
49864
49883
  }
49865
49884
  else {
49866
49885
  var tsExtension = ts.tryExtractTSExtension(moduleReference);
49886
+ var isExtensionlessRelativePathImport = ts.pathIsRelative(moduleReference) && !ts.hasExtension(moduleReference);
49887
+ var moduleResolutionKind = ts.getEmitModuleResolutionKind(compilerOptions);
49888
+ var resolutionIsNode12OrNext = moduleResolutionKind === ts.ModuleResolutionKind.Node12 ||
49889
+ moduleResolutionKind === ts.ModuleResolutionKind.NodeNext;
49867
49890
  if (tsExtension) {
49868
49891
  var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
49869
49892
  var importSourceWithoutExtension = ts.removeExtension(moduleReference, tsExtension);
@@ -49883,6 +49906,19 @@ var ts;
49883
49906
  ts.hasJsonModuleEmitEnabled(compilerOptions)) {
49884
49907
  error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
49885
49908
  }
49909
+ else if (mode === ts.ModuleKind.ESNext && resolutionIsNode12OrNext && isExtensionlessRelativePathImport) {
49910
+ var absoluteRef_1 = ts.getNormalizedAbsolutePath(moduleReference, ts.getDirectoryPath(currentSourceFile.path));
49911
+ var suggestedExt = (_g = suggestedExtensions.find(function (_a) {
49912
+ var actualExt = _a[0], _importExt = _a[1];
49913
+ return host.fileExists(absoluteRef_1 + actualExt);
49914
+ })) === null || _g === void 0 ? void 0 : _g[1];
49915
+ if (suggestedExt) {
49916
+ 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);
49917
+ }
49918
+ else {
49919
+ 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);
49920
+ }
49921
+ }
49886
49922
  else {
49887
49923
  error(errorNode, moduleNotFoundError, moduleReference);
49888
49924
  }
@@ -61795,7 +61831,8 @@ var ts;
61795
61831
  if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
61796
61832
  if (!type.declaration.nameType) {
61797
61833
  var constraint = void 0;
61798
- if (isArrayType(t) || (t.flags & 1 /* Any */) && (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
61834
+ if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
61835
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
61799
61836
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
61800
61837
  }
61801
61838
  if (isGenericTupleType(t)) {
@@ -78514,7 +78551,9 @@ var ts;
78514
78551
  var typeReferenceNode = ts.tryCast(node.parent, ts.isTypeReferenceType);
78515
78552
  if (!typeReferenceNode)
78516
78553
  return undefined;
78517
- var typeParameters = getTypeParametersForTypeReference(typeReferenceNode); // TODO: GH#18217
78554
+ var typeParameters = getTypeParametersForTypeReference(typeReferenceNode);
78555
+ if (!typeParameters)
78556
+ return undefined;
78518
78557
  var constraint = getConstraintOfTypeParameter(typeParameters[typeReferenceNode.typeArguments.indexOf(node)]);
78519
78558
  return constraint && instantiateType(constraint, createTypeMapper(typeParameters, getEffectiveTypeArguments(typeReferenceNode, typeParameters)));
78520
78559
  }
@@ -95098,11 +95137,11 @@ var ts;
95098
95137
  currentFileState.filenameDeclaration = declaration;
95099
95138
  return currentFileState.filenameDeclaration.name;
95100
95139
  }
95101
- function getJsxFactoryCalleePrimitive(childrenLength) {
95102
- return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : childrenLength > 1 ? "jsxs" : "jsx";
95140
+ function getJsxFactoryCalleePrimitive(isStaticChildren) {
95141
+ return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx";
95103
95142
  }
95104
- function getJsxFactoryCallee(childrenLength) {
95105
- var type = getJsxFactoryCalleePrimitive(childrenLength);
95143
+ function getJsxFactoryCallee(isStaticChildren) {
95144
+ var type = getJsxFactoryCalleePrimitive(isStaticChildren);
95106
95145
  return getImplicitImportForName(type);
95107
95146
  }
95108
95147
  function getImplicitJsxFragmentReference() {
@@ -95254,7 +95293,7 @@ var ts;
95254
95293
  }
95255
95294
  function convertJsxChildrenToChildrenPropAssignment(children) {
95256
95295
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95257
- if (ts.length(nonWhitespaceChildren) === 1) {
95296
+ if (ts.length(nonWhitespaceChildren) === 1 && !nonWhitespaceChildren[0].dotDotDotToken) {
95258
95297
  var result_12 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
95259
95298
  return result_12 && factory.createPropertyAssignment("children", result_12);
95260
95299
  }
@@ -95268,15 +95307,18 @@ var ts;
95268
95307
  var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties;
95269
95308
  var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs, childrenProp) :
95270
95309
  factory.createObjectLiteralExpression(childrenProp ? [childrenProp] : ts.emptyArray); // When there are no attributes, React wants {}
95271
- return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, ts.length(ts.getSemanticJsxChildren(children || ts.emptyArray)), isChild, location);
95310
+ return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, children || ts.emptyArray, isChild, location);
95272
95311
  }
95273
- function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, childrenLength, isChild, location) {
95312
+ function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, children, isChild, location) {
95313
+ var _a;
95314
+ var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95315
+ var isStaticChildren = ts.length(nonWhitespaceChildren) > 1 || !!((_a = nonWhitespaceChildren[0]) === null || _a === void 0 ? void 0 : _a.dotDotDotToken);
95274
95316
  var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)];
95275
95317
  if (compilerOptions.jsx === 5 /* ReactJSXDev */) {
95276
95318
  var originalFile = ts.getOriginalNode(currentSourceFile);
95277
95319
  if (originalFile && ts.isSourceFile(originalFile)) {
95278
95320
  // isStaticChildren development flag
95279
- args.push(childrenLength > 1 ? factory.createTrue() : factory.createFalse());
95321
+ args.push(isStaticChildren ? factory.createTrue() : factory.createFalse());
95280
95322
  // __source development flag
95281
95323
  var lineCol = ts.getLineAndCharacterOfPosition(originalFile, location.pos);
95282
95324
  args.push(factory.createObjectLiteralExpression([
@@ -95288,7 +95330,7 @@ var ts;
95288
95330
  args.push(factory.createThis());
95289
95331
  }
95290
95332
  }
95291
- var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(childrenLength), /*typeArguments*/ undefined, args), location);
95333
+ var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(isStaticChildren), /*typeArguments*/ undefined, args), location);
95292
95334
  if (isChild) {
95293
95335
  ts.startOnNewLine(element);
95294
95336
  }
@@ -95318,7 +95360,7 @@ var ts;
95318
95360
  }
95319
95361
  }
95320
95362
  return visitJsxOpeningLikeElementOrFragmentJSX(getImplicitJsxFragmentReference(), childrenProps || factory.createObjectLiteralExpression([]),
95321
- /*keyAttr*/ undefined, ts.length(ts.getSemanticJsxChildren(children)), isChild, location);
95363
+ /*keyAttr*/ undefined, children, isChild, location);
95322
95364
  }
95323
95365
  function visitJsxOpeningFragmentCreateElement(node, children, isChild, location) {
95324
95366
  var element = ts.createExpressionForJsxFragment(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), context.getEmitResolver().getJsxFragmentFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217
@@ -114394,8 +114436,8 @@ var ts;
114394
114436
  var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
114395
114437
  var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
114396
114438
  // ensure that types resolutions are still correct
114397
- var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
114398
- if (typeReferenceEesolutionsChanged) {
114439
+ var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
114440
+ if (typeReferenceResolutionsChanged) {
114399
114441
  structureIsReused = 1 /* SafeModules */;
114400
114442
  newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
114401
114443
  }
@@ -115683,6 +115725,21 @@ var ts;
115683
115725
  return resolvedRef;
115684
115726
  }
115685
115727
  function verifyCompilerOptions() {
115728
+ var isNightly = ts.stringContains(ts.version, "-dev");
115729
+ if (!isNightly) {
115730
+ if (ts.getEmitModuleKind(options) === ts.ModuleKind.Node12) {
115731
+ 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");
115732
+ }
115733
+ else if (ts.getEmitModuleKind(options) === ts.ModuleKind.NodeNext) {
115734
+ 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");
115735
+ }
115736
+ else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12) {
115737
+ 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");
115738
+ }
115739
+ else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
115740
+ 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");
115741
+ }
115742
+ }
115686
115743
  if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
115687
115744
  createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
115688
115745
  }
@@ -116161,8 +116218,8 @@ var ts;
116161
116218
  function createDiagnosticForOptionName(message, option1, option2, option3) {
116162
116219
  createDiagnosticForOption(/*onKey*/ true, option1, option2, message, option1, option2, option3);
116163
116220
  }
116164
- function createOptionValueDiagnostic(option1, message, arg0) {
116165
- createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0);
116221
+ function createOptionValueDiagnostic(option1, message, arg0, arg1) {
116222
+ createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0, arg1);
116166
116223
  }
116167
116224
  function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) {
116168
116225
  var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; });
@@ -118406,6 +118463,9 @@ var ts;
118406
118463
  else {
118407
118464
  resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
118408
118465
  perDirectoryResolution.set(name, mode, resolution);
118466
+ if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
118467
+ resolutionHost.onDiscoveredSymlink();
118468
+ }
118409
118469
  }
118410
118470
  resolutionsInFile.set(name, mode, resolution);
118411
118471
  watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
@@ -118874,6 +118934,11 @@ var ts;
118874
118934
  }
118875
118935
  }
118876
118936
  ts.createResolutionCache = createResolutionCache;
118937
+ function resolutionIsSymlink(resolution) {
118938
+ var _a, _b;
118939
+ return !!(((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.originalPath) ||
118940
+ ((_b = resolution.resolvedTypeReferenceDirective) === null || _b === void 0 ? void 0 : _b.originalPath));
118941
+ }
118877
118942
  })(ts || (ts = {}));
118878
118943
  // Used by importFixes, getEditsForFileRename, and declaration emit to synthesize import module specifiers.
118879
118944
  /* @internal */
@@ -126320,6 +126385,12 @@ var ts;
126320
126385
  return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */;
126321
126386
  }
126322
126387
  ts.getNewLineKind = getNewLineKind;
126388
+ function diagnosticToString(diag) {
126389
+ return ts.isArray(diag)
126390
+ ? ts.formatStringFromArgs(ts.getLocaleSpecificMessage(diag[0]), diag.slice(1))
126391
+ : ts.getLocaleSpecificMessage(diag);
126392
+ }
126393
+ ts.diagnosticToString = diagnosticToString;
126323
126394
  // #endregion
126324
126395
  })(ts || (ts = {}));
126325
126396
  /*@internal*/
@@ -128666,6 +128737,8 @@ var ts;
128666
128737
  (function (CompletionSource) {
128667
128738
  /** Completions that require `this.` insertion text */
128668
128739
  CompletionSource["ThisProperty"] = "ThisProperty/";
128740
+ /** Auto-import that comes attached to a class member snippet */
128741
+ CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
128669
128742
  })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
128670
128743
  var SymbolOriginInfoKind;
128671
128744
  (function (SymbolOriginInfoKind) {
@@ -129028,6 +129101,7 @@ var ts;
129028
129101
  var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
129029
129102
  var data;
129030
129103
  var isSnippet;
129104
+ var source = getSourceFromOrigin(origin);
129031
129105
  var sourceDisplay;
129032
129106
  var hasAction;
129033
129107
  var typeChecker = program.getTypeChecker();
@@ -129085,7 +129159,12 @@ var ts;
129085
129159
  preferences.includeCompletionsWithInsertText &&
129086
129160
  completionKind === 3 /* MemberLike */ &&
129087
129161
  isClassLikeMemberCompletion(symbol, location)) {
129088
- (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet);
129162
+ var importAdder = void 0;
129163
+ (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder);
129164
+ if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
129165
+ hasAction = true;
129166
+ source = CompletionSource.ClassMemberSnippet;
129167
+ }
129089
129168
  }
129090
129169
  var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location);
129091
129170
  if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
@@ -129132,7 +129211,7 @@ var ts;
129132
129211
  kind: kind,
129133
129212
  kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol),
129134
129213
  sortText: sortText,
129135
- source: getSourceFromOrigin(origin),
129214
+ source: source,
129136
129215
  hasAction: hasAction ? true : undefined,
129137
129216
  isRecommended: isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker) || undefined,
129138
129217
  insertText: insertText,
@@ -129201,15 +129280,14 @@ var ts;
129201
129280
  });
129202
129281
  var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
129203
129282
  var body;
129204
- var tabstopStart = 1;
129205
129283
  if (preferences.includeCompletionsWithSnippetText) {
129206
129284
  isSnippet = true;
129207
- // We are adding a final tabstop (i.e. $0) in the body of the suggested member, if it has one.
129285
+ // We are adding a tabstop (i.e. `$0`) in the body of the suggested member,
129286
+ // if it has one, so that the cursor ends up in the body once the completion is inserted.
129208
129287
  // Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
129209
- var emptyStatement1 = ts.factory.createExpressionStatement(ts.factory.createIdentifier(""));
129210
- ts.setSnippetElement(emptyStatement1, { kind: 0 /* TabStop */, order: 1 });
129211
- tabstopStart = 2;
129212
- body = ts.factory.createBlock([emptyStatement1], /* multiline */ true);
129288
+ var emptyStatement = ts.factory.createExpressionStatement(ts.factory.createIdentifier(""));
129289
+ ts.setSnippetElement(emptyStatement, { kind: 0 /* TabStop */, order: 0 });
129290
+ body = ts.factory.createBlock([emptyStatement], /* multiline */ true);
129213
129291
  }
129214
129292
  else {
129215
129293
  body = ts.factory.createBlock([], /* multiline */ true);
@@ -129255,12 +129333,9 @@ var ts;
129255
129333
  completionNodes.push(node);
129256
129334
  }, body, isAbstract);
129257
129335
  if (completionNodes.length) {
129258
- if (preferences.includeCompletionsWithSnippetText) {
129259
- addSnippets(completionNodes, tabstopStart);
129260
- }
129261
129336
  insertText = printer.printSnippetList(1 /* MultiLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
129262
129337
  }
129263
- return { insertText: insertText, isSnippet: isSnippet };
129338
+ return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder };
129264
129339
  }
129265
129340
  function getPresentModifiers(contextToken) {
129266
129341
  var modifiers = 0 /* None */;
@@ -129301,33 +129376,6 @@ var ts;
129301
129376
  }
129302
129377
  return undefined;
129303
129378
  }
129304
- function addSnippets(nodes, orderStart) {
129305
- var order = orderStart;
129306
- for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
129307
- var node = nodes_1[_i];
129308
- addSnippetsWorker(node, /*parent*/ undefined);
129309
- }
129310
- function addSnippetsWorker(node, parent) {
129311
- if (ts.isVariableLike(node) && node.kind === 163 /* Parameter */) {
129312
- // Placeholder
129313
- ts.setSnippetElement(node.name, { kind: 1 /* Placeholder */, order: order });
129314
- order += 1;
129315
- if (node.type) {
129316
- ts.setSnippetElement(node.type, { kind: 1 /* Placeholder */, order: order });
129317
- order += 1;
129318
- }
129319
- }
129320
- else if (ts.isTypeNode(node) && parent && ts.isFunctionLikeDeclaration(parent)) {
129321
- ts.setSnippetElement(node, { kind: 1 /* Placeholder */, order: order });
129322
- order += 1;
129323
- }
129324
- else if (ts.isTypeParameterDeclaration(node) && parent && ts.isFunctionLikeDeclaration(parent)) {
129325
- ts.setSnippetElement(node, { kind: 1 /* Placeholder */, order: order });
129326
- order += 1;
129327
- }
129328
- ts.forEachChild(node, function (child) { return addSnippetsWorker(child, node); });
129329
- }
129330
- }
129331
129379
  function createSnippetPrinter(printerOptions) {
129332
129380
  var printer = ts.createPrinter(printerOptions);
129333
129381
  var baseWriter = ts.createTextWriter(ts.getNewLineCharacter(printerOptions));
@@ -129549,11 +129597,13 @@ var ts;
129549
129597
  if (entryId.data) {
129550
129598
  var autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host);
129551
129599
  if (autoImport) {
129600
+ var _a = getRelevantTokens(position, sourceFile), contextToken_1 = _a.contextToken, previousToken_1 = _a.previousToken;
129552
129601
  return {
129553
129602
  type: "symbol",
129554
129603
  symbol: autoImport.symbol,
129555
129604
  location: ts.getTouchingPropertyName(sourceFile, position),
129556
- previousToken: ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined),
129605
+ previousToken: previousToken_1,
129606
+ contextToken: contextToken_1,
129557
129607
  isJsxInitializer: false,
129558
129608
  isTypeOnlyLocation: false,
129559
129609
  origin: autoImport.origin,
@@ -129568,7 +129618,7 @@ var ts;
129568
129618
  if (completionData.kind !== 0 /* Data */) {
129569
129619
  return { type: "request", request: completionData };
129570
129620
  }
129571
- 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;
129621
+ 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;
129572
129622
  var literal = ts.find(literals, function (l) { return completionNameForLiteral(sourceFile, preferences, l) === entryId.name; });
129573
129623
  if (literal !== undefined)
129574
129624
  return { type: "literal", literal: literal };
@@ -129579,15 +129629,15 @@ var ts;
129579
129629
  return ts.firstDefined(symbols, function (symbol, index) {
129580
129630
  var origin = symbolToOriginInfoMap[index];
129581
129631
  var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
129582
- return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source
129583
- ? { type: "symbol", symbol: symbol, location: location, origin: origin, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
129632
+ return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ || getSourceFromOrigin(origin) === entryId.source)
129633
+ ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
129584
129634
  : undefined;
129585
129635
  }) || { type: "none" };
129586
129636
  }
129587
129637
  function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) {
129588
129638
  var typeChecker = program.getTypeChecker();
129589
129639
  var compilerOptions = program.getCompilerOptions();
129590
- var name = entryId.name;
129640
+ var name = entryId.name, source = entryId.source, data = entryId.data;
129591
129641
  var contextToken = ts.findPrecedingToken(position, sourceFile);
129592
129642
  if (ts.isInString(sourceFile, position, contextToken)) {
129593
129643
  return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken, preferences);
@@ -129611,8 +129661,8 @@ var ts;
129611
129661
  }
129612
129662
  }
129613
129663
  case "symbol": {
129614
- var symbol = symbolCompletion.symbol, location = symbolCompletion.location, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken;
129615
- var _a = getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, entryId.data), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay;
129664
+ var symbol = symbolCompletion.symbol, location = symbolCompletion.location, contextToken_2 = symbolCompletion.contextToken, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken;
129665
+ 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;
129616
129666
  return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217
129617
129667
  }
129618
129668
  case "literal": {
@@ -129641,14 +129691,27 @@ var ts;
129641
129691
  return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source, sourceDisplay: source };
129642
129692
  }
129643
129693
  Completions.createCompletionDetails = createCompletionDetails;
129644
- function getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data) {
129694
+ function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source) {
129645
129695
  if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
129646
- var _a = getRelevantTokens(position, sourceFile), contextToken = _a.contextToken, previousToken_1 = _a.previousToken;
129647
- if (previousToken_1 && getImportStatementCompletionInfo(contextToken || previousToken_1).replacementNode) {
129696
+ var _a = getRelevantTokens(position, sourceFile), contextToken_3 = _a.contextToken, previousToken_2 = _a.previousToken;
129697
+ if (previousToken_2 && getImportStatementCompletionInfo(contextToken_3 || previousToken_2).replacementNode) {
129648
129698
  // Import statement completion: 'import c|'
129649
129699
  return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
129650
129700
  }
129651
129701
  }
129702
+ if (source === CompletionSource.ClassMemberSnippet) {
129703
+ var importAdder = getEntryForMemberCompletion(host, program, compilerOptions, preferences, name, symbol, location, contextToken).importAdder;
129704
+ if (importAdder) {
129705
+ var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
129706
+ return {
129707
+ sourceDisplay: undefined,
129708
+ codeActions: [{
129709
+ changes: changes,
129710
+ description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
129711
+ }],
129712
+ };
129713
+ }
129714
+ }
129652
129715
  if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
129653
129716
  return { codeActions: undefined, sourceDisplay: undefined };
129654
129717
  }
@@ -134810,7 +134873,8 @@ var ts;
134810
134873
  }
134811
134874
  }
134812
134875
  else {
134813
- return nodeEntry(ref, 2 /* StringLiteral */);
134876
+ return ts.isNoSubstitutionTemplateLiteral(ref) && !ts.rangeIsOnSingleLine(ref, sourceFile) ? undefined :
134877
+ nodeEntry(ref, 2 /* StringLiteral */);
134814
134878
  }
134815
134879
  }
134816
134880
  });
@@ -144848,8 +144912,8 @@ var ts;
144848
144912
  ChangeTracker.prototype.deleteNodes = function (sourceFile, nodes, options, hasTrailingComment) {
144849
144913
  if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
144850
144914
  // When deleting multiple nodes we need to track if the end position is including multiline trailing comments.
144851
- for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
144852
- var node = nodes_2[_i];
144915
+ for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
144916
+ var node = nodes_1[_i];
144853
144917
  var pos = getAdjustedStartPosition(sourceFile, node, options, hasTrailingComment);
144854
144918
  var end = getAdjustedEndPosition(sourceFile, node, options);
144855
144919
  this.deleteRange(sourceFile, { pos: pos, end: end });
@@ -145954,21 +146018,16 @@ var ts;
145954
146018
  (function (codefix) {
145955
146019
  var errorCodeToFixes = ts.createMultiMap();
145956
146020
  var fixIdToRegistration = new ts.Map();
145957
- function diagnosticToString(diag) {
145958
- return ts.isArray(diag)
145959
- ? ts.formatStringFromArgs(ts.getLocaleSpecificMessage(diag[0]), diag.slice(1))
145960
- : ts.getLocaleSpecificMessage(diag);
145961
- }
145962
146021
  function createCodeFixActionWithoutFixAll(fixName, changes, description) {
145963
- return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, /*fixId*/ undefined, /*fixAllDescription*/ undefined);
146022
+ return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, /*fixId*/ undefined, /*fixAllDescription*/ undefined);
145964
146023
  }
145965
146024
  codefix.createCodeFixActionWithoutFixAll = createCodeFixActionWithoutFixAll;
145966
146025
  function createCodeFixAction(fixName, changes, description, fixId, fixAllDescription, command) {
145967
- return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, diagnosticToString(fixAllDescription), command);
146026
+ return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, fixId, ts.diagnosticToString(fixAllDescription), command);
145968
146027
  }
145969
146028
  codefix.createCodeFixAction = createCodeFixAction;
145970
146029
  function createCodeFixActionMaybeFixAll(fixName, changes, description, fixId, fixAllDescription, command) {
145971
- return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, fixAllDescription && diagnosticToString(fixAllDescription), command);
146030
+ return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, fixId, fixAllDescription && ts.diagnosticToString(fixAllDescription), command);
145972
146031
  }
145973
146032
  codefix.createCodeFixActionMaybeFixAll = createCodeFixActionMaybeFixAll;
145974
146033
  function createCodeFixActionWorker(fixName, description, changes, fixId, fixAllDescription, command) {
@@ -148729,7 +148788,7 @@ var ts;
148729
148788
  var addToExisting = new ts.Map();
148730
148789
  /** Use `getNewImportEntry` for access */
148731
148790
  var newImports = new ts.Map();
148732
- return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes };
148791
+ return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes, hasFixes: hasFixes };
148733
148792
  function addImportFromDiagnostic(diagnostic, context) {
148734
148793
  var info = getFixesInfo(context, diagnostic.code, diagnostic.start, useAutoImportProvider);
148735
148794
  if (!info || !info.fixes.length)
@@ -148880,6 +148939,9 @@ var ts;
148880
148939
  ts.insertImports(changeTracker, sourceFile, newDeclarations, /*blankLineBetween*/ true);
148881
148940
  }
148882
148941
  }
148942
+ function hasFixes() {
148943
+ return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0;
148944
+ }
148883
148945
  }
148884
148946
  // Sorted with the preferred fix coming first.
148885
148947
  var ImportFixKind;
@@ -159401,8 +159463,8 @@ var ts;
159401
159463
  var list = createNode(346 /* SyntaxList */, nodes.pos, nodes.end, parent);
159402
159464
  list._children = [];
159403
159465
  var pos = nodes.pos;
159404
- for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) {
159405
- var node = nodes_3[_i];
159466
+ for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
159467
+ var node = nodes_2[_i];
159406
159468
  addSyntheticNodes(list._children, pos, node.pos, parent);
159407
159469
  list._children.push(node);
159408
159470
  pos = node.end;
@@ -14,7 +14,7 @@ and limitations under the License.
14
14
  ***************************************************************************** */
15
15
 
16
16
  declare namespace ts {
17
- const versionMajorMinor = "4.5";
17
+ const versionMajorMinor = "4.6";
18
18
  /** The version of the TypeScript compiler release */
19
19
  const version: string;
20
20
  /**