typescript 4.5.0-dev.20211026 → 4.5.0-dev.20211030

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
@@ -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.20211026";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20211030";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -2745,6 +2745,10 @@ var ts;
2745
2745
  return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
2746
2746
  }
2747
2747
  Debug.formatSyntaxKind = formatSyntaxKind;
2748
+ function formatSnippetKind(kind) {
2749
+ return formatEnum(kind, ts.SnippetKind, /*isFlags*/ false);
2750
+ }
2751
+ Debug.formatSnippetKind = formatSnippetKind;
2748
2752
  function formatNodeFlags(flags) {
2749
2753
  return formatEnum(flags, ts.NodeFlags, /*isFlags*/ true);
2750
2754
  }
@@ -4661,6 +4665,13 @@ var ts;
4661
4665
  ExitStatus[ExitStatus["ProjectReferenceCycle_OutputsSkupped"] = 4] = "ProjectReferenceCycle_OutputsSkupped";
4662
4666
  })(ExitStatus = ts.ExitStatus || (ts.ExitStatus = {}));
4663
4667
  /* @internal */
4668
+ var MemberOverrideStatus;
4669
+ (function (MemberOverrideStatus) {
4670
+ MemberOverrideStatus[MemberOverrideStatus["Ok"] = 0] = "Ok";
4671
+ MemberOverrideStatus[MemberOverrideStatus["NeedsOverride"] = 1] = "NeedsOverride";
4672
+ MemberOverrideStatus[MemberOverrideStatus["HasInvalidOverride"] = 2] = "HasInvalidOverride";
4673
+ })(MemberOverrideStatus = ts.MemberOverrideStatus || (ts.MemberOverrideStatus = {}));
4674
+ /* @internal */
4664
4675
  var UnionReduction;
4665
4676
  (function (UnionReduction) {
4666
4677
  UnionReduction[UnionReduction["None"] = 0] = "None";
@@ -5309,7 +5320,7 @@ var ts;
5309
5320
  (function (ModuleResolutionKind) {
5310
5321
  ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
5311
5322
  ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
5312
- // 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
5313
5324
  // to better support ecmascript modules and their use within node - more features are still being added, so
5314
5325
  // we can expect it to change over time, and as such, offer both a `NodeNext` moving resolution target, and a `Node12`
5315
5326
  // version-anchored resolution target
@@ -5642,6 +5653,15 @@ var ts;
5642
5653
  // Masks
5643
5654
  // - Additional bitmasks
5644
5655
  })(TransformFlags = ts.TransformFlags || (ts.TransformFlags = {}));
5656
+ // Reference: https://code.visualstudio.com/docs/editor/userdefinedsnippets#_snippet-syntax
5657
+ /* @internal */
5658
+ var SnippetKind;
5659
+ (function (SnippetKind) {
5660
+ SnippetKind[SnippetKind["TabStop"] = 0] = "TabStop";
5661
+ SnippetKind[SnippetKind["Placeholder"] = 1] = "Placeholder";
5662
+ SnippetKind[SnippetKind["Choice"] = 2] = "Choice";
5663
+ SnippetKind[SnippetKind["Variable"] = 3] = "Variable";
5664
+ })(SnippetKind = ts.SnippetKind || (ts.SnippetKind = {}));
5645
5665
  var EmitFlags;
5646
5666
  (function (EmitFlags) {
5647
5667
  EmitFlags[EmitFlags["None"] = 0] = "None";
@@ -8878,6 +8898,8 @@ var ts;
8878
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'."),
8879
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."),
8880
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}'?"),
8881
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}'."),
8882
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}'."),
8883
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}'."),
@@ -8984,6 +9006,7 @@ var ts;
8984
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."),
8985
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}'."),
8986
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'."),
8987
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."),
8988
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."),
8989
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}'."),
@@ -9537,6 +9560,7 @@ var ts;
9537
9560
  This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead: diag(7059, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Use_an_as_expression_instead_7059", "This syntax is reserved in files with the .mts or .cts extension. Use an `as` expression instead."),
9538
9561
  This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_constraint: diag(7060, ts.DiagnosticCategory.Error, "This_syntax_is_reserved_in_files_with_the_mts_or_cts_extension_Add_a_trailing_comma_or_explicit_cons_7060", "This syntax is reserved in files with the .mts or .cts extension. Add a trailing comma or explicit constraint."),
9539
9562
  A_mapped_type_may_not_declare_properties_or_methods: diag(7061, ts.DiagnosticCategory.Error, "A_mapped_type_may_not_declare_properties_or_methods_7061", "A mapped type may not declare properties or methods."),
9563
+ JSON_imports_are_experimental_in_ES_module_mode_imports: diag(7062, ts.DiagnosticCategory.Error, "JSON_imports_are_experimental_in_ES_module_mode_imports_7062", "JSON imports are experimental in ES module mode imports."),
9540
9564
  You_cannot_rename_this_element: diag(8000, ts.DiagnosticCategory.Error, "You_cannot_rename_this_element_8000", "You cannot rename this element."),
9541
9565
  You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library: diag(8001, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_the_standard_TypeScript_library_8001", "You cannot rename elements that are defined in the standard TypeScript library."),
9542
9566
  import_can_only_be_used_in_TypeScript_files: diag(8002, ts.DiagnosticCategory.Error, "import_can_only_be_used_in_TypeScript_files_8002", "'import ... =' can only be used in TypeScript files."),
@@ -9640,6 +9664,7 @@ var ts;
9640
9664
  Remove_unused_destructuring_declaration: diag(90039, ts.DiagnosticCategory.Message, "Remove_unused_destructuring_declaration_90039", "Remove unused destructuring declaration"),
9641
9665
  Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
9642
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}'"),
9643
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"),
9644
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}'"),
9645
9670
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -19833,6 +19858,8 @@ var ts;
19833
19858
  case ts.ModuleKind.ES2020:
19834
19859
  case ts.ModuleKind.ES2022:
19835
19860
  case ts.ModuleKind.ESNext:
19861
+ case ts.ModuleKind.Node12:
19862
+ case ts.ModuleKind.NodeNext:
19836
19863
  return true;
19837
19864
  default:
19838
19865
  return false;
@@ -20944,6 +20971,10 @@ var ts;
20944
20971
  return node.kind === 212 /* FunctionExpression */ || node.kind === 213 /* ArrowFunction */;
20945
20972
  }
20946
20973
  ts.isFunctionExpressionOrArrowFunction = isFunctionExpressionOrArrowFunction;
20974
+ function escapeSnippetText(text) {
20975
+ return text.replace(/\$/gm, "\\$");
20976
+ }
20977
+ ts.escapeSnippetText = escapeSnippetText;
20947
20978
  })(ts || (ts = {}));
20948
20979
  /* @internal */
20949
20980
  var ts;
@@ -27147,6 +27178,25 @@ var ts;
27147
27178
  }
27148
27179
  }
27149
27180
  ts.moveEmitHelpers = moveEmitHelpers;
27181
+ /**
27182
+ * Gets the SnippetElement of a node.
27183
+ */
27184
+ /* @internal */
27185
+ function getSnippetElement(node) {
27186
+ var _a;
27187
+ return (_a = node.emitNode) === null || _a === void 0 ? void 0 : _a.snippetElement;
27188
+ }
27189
+ ts.getSnippetElement = getSnippetElement;
27190
+ /**
27191
+ * Sets the SnippetElement of a node.
27192
+ */
27193
+ /* @internal */
27194
+ function setSnippetElement(node, snippet) {
27195
+ var emitNode = getOrCreateEmitNode(node);
27196
+ emitNode.snippetElement = snippet;
27197
+ return node;
27198
+ }
27199
+ ts.setSnippetElement = setSnippetElement;
27150
27200
  /* @internal */
27151
27201
  function ignoreSourceNewlines(node) {
27152
27202
  getOrCreateEmitNode(node).flags |= 134217728 /* IgnoreSourceNewlines */;
@@ -47272,6 +47322,7 @@ var ts;
47272
47322
  isDeclarationVisible: isDeclarationVisible,
47273
47323
  isPropertyAccessible: isPropertyAccessible,
47274
47324
  getTypeOnlyAliasDeclaration: getTypeOnlyAliasDeclaration,
47325
+ getMemberOverrideModifierStatus: getMemberOverrideModifierStatus,
47275
47326
  };
47276
47327
  function getResolvedSignatureWorker(nodeIn, candidatesOutArray, argumentCount, checkMode) {
47277
47328
  var node = ts.getParseTreeNode(nodeIn, ts.isCallLikeExpression);
@@ -47515,6 +47566,21 @@ var ts;
47515
47566
  var enumRelation = new ts.Map();
47516
47567
  var builtinGlobals = ts.createSymbolTable();
47517
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
+ ];
47518
47584
  initializeTypeChecker();
47519
47585
  return checker;
47520
47586
  function getJsxNamespace(location) {
@@ -49018,6 +49084,10 @@ var ts;
49018
49084
  function isESMFormatImportImportingCommonjsFormatFile(usageMode, targetMode) {
49019
49085
  return usageMode === ts.ModuleKind.ESNext && targetMode === ts.ModuleKind.CommonJS;
49020
49086
  }
49087
+ function isOnlyImportedAsDefault(usage) {
49088
+ var usageMode = getUsageModeForExpression(usage);
49089
+ return usageMode === ts.ModuleKind.ESNext && ts.endsWith(usage.text, ".json" /* Json */);
49090
+ }
49021
49091
  function canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, usage) {
49022
49092
  var usageMode = file && getUsageModeForExpression(usage);
49023
49093
  if (file && usageMode !== undefined) {
@@ -49068,8 +49138,9 @@ var ts;
49068
49138
  exportDefaultSymbol = resolveExportByName(moduleSymbol, "default" /* Default */, node, dontResolveAlias);
49069
49139
  }
49070
49140
  var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
49141
+ var hasDefaultOnly = isOnlyImportedAsDefault(node.parent.moduleSpecifier);
49071
49142
  var hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, node.parent.moduleSpecifier);
49072
- if (!exportDefaultSymbol && !hasSyntheticDefault) {
49143
+ if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
49073
49144
  if (hasExportAssignmentSymbol(moduleSymbol)) {
49074
49145
  var compilerOptionName = moduleKind >= ts.ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
49075
49146
  var exportEqualsSymbol = moduleSymbol.exports.get("export=" /* ExportEquals */);
@@ -49083,7 +49154,7 @@ var ts;
49083
49154
  reportNonDefaultExport(moduleSymbol, node);
49084
49155
  }
49085
49156
  }
49086
- else if (hasSyntheticDefault) {
49157
+ else if (hasSyntheticDefault || hasDefaultOnly) {
49087
49158
  // per emit behavior, a synthetic default overrides a "real" .default member if `__esModule` is not present
49088
49159
  var resolved = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
49089
49160
  markSymbolOfAliasDeclarationIfTypeOnly(node, moduleSymbol, resolved, /*overwriteTypeOnly*/ false);
@@ -49208,7 +49279,7 @@ var ts;
49208
49279
  var symbolFromModule = getExportOfModule(targetSymbol, name, specifier, dontResolveAlias);
49209
49280
  if (symbolFromModule === undefined && name.escapedText === "default" /* Default */) {
49210
49281
  var file = (_a = moduleSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
49211
- if (canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
49282
+ if (isOnlyImportedAsDefault(moduleSpecifier) || canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, moduleSpecifier)) {
49212
49283
  symbolFromModule = resolveExternalModuleSymbol(moduleSymbol, dontResolveAlias) || resolveSymbol(moduleSymbol, dontResolveAlias);
49213
49284
  }
49214
49285
  }
@@ -49725,7 +49796,7 @@ var ts;
49725
49796
  : undefined;
49726
49797
  }
49727
49798
  function resolveExternalModule(location, moduleReference, moduleNotFoundError, errorNode, isForAugmentation) {
49728
- var _a, _b, _c, _d, _e, _f;
49799
+ var _a, _b, _c, _d, _e, _f, _g;
49729
49800
  if (isForAugmentation === void 0) { isForAugmentation = false; }
49730
49801
  if (ts.startsWith(moduleReference, "@types/")) {
49731
49802
  var diag = ts.Diagnostics.Cannot_import_type_declaration_files_Consider_importing_0_instead_of_1;
@@ -49746,7 +49817,7 @@ var ts;
49746
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) ||
49747
49818
  ((_f = (ts.isLiteralImportTypeNode(location) ? location : undefined)) === null || _f === void 0 ? void 0 : _f.argument.literal);
49748
49819
  var mode = contextSpecifier && ts.isStringLiteralLike(contextSpecifier) ? ts.getModeForUsageLocation(currentSourceFile, contextSpecifier) : currentSourceFile.impliedNodeFormat;
49749
- var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode); // TODO: GH#18217
49820
+ var resolvedModule = ts.getResolvedModule(currentSourceFile, moduleReference, mode);
49750
49821
  var resolutionDiagnostic = resolvedModule && ts.getResolutionDiagnostic(compilerOptions, resolvedModule);
49751
49822
  var sourceFile = resolvedModule && !resolutionDiagnostic && host.getSourceFile(resolvedModule.resolvedFileName);
49752
49823
  if (sourceFile) {
@@ -49759,6 +49830,9 @@ var ts;
49759
49830
  if (isSyncImport && sourceFile.impliedNodeFormat === ts.ModuleKind.ESNext) {
49760
49831
  error(errorNode, ts.Diagnostics.Module_0_cannot_be_imported_using_this_construct_The_specifier_only_resolves_to_an_ES_module_which_cannot_be_imported_synchronously_Use_dynamic_import_instead, moduleReference);
49761
49832
  }
49833
+ if (mode === ts.ModuleKind.ESNext && compilerOptions.resolveJsonModule && resolvedModule.extension === ".json" /* Json */) {
49834
+ error(errorNode, ts.Diagnostics.JSON_imports_are_experimental_in_ES_module_mode_imports);
49835
+ }
49762
49836
  }
49763
49837
  // merged symbol is module declaration symbol combined with all augmentations
49764
49838
  return getMergedSymbol(sourceFile.symbol);
@@ -49809,6 +49883,10 @@ var ts;
49809
49883
  }
49810
49884
  else {
49811
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;
49812
49890
  if (tsExtension) {
49813
49891
  var diag = ts.Diagnostics.An_import_path_cannot_end_with_a_0_extension_Consider_importing_1_instead;
49814
49892
  var importSourceWithoutExtension = ts.removeExtension(moduleReference, tsExtension);
@@ -49828,6 +49906,19 @@ var ts;
49828
49906
  ts.hasJsonModuleEmitEnabled(compilerOptions)) {
49829
49907
  error(errorNode, ts.Diagnostics.Cannot_find_module_0_Consider_using_resolveJsonModule_to_import_module_with_json_extension, moduleReference);
49830
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
+ }
49831
49922
  else {
49832
49923
  error(errorNode, moduleNotFoundError, moduleReference);
49833
49924
  }
@@ -49897,40 +49988,50 @@ var ts;
49897
49988
  error(referencingLocation, ts.Diagnostics.This_module_can_only_be_referenced_with_ECMAScript_imports_Slashexports_by_turning_on_the_0_flag_and_referencing_its_default_export, compilerOptionName);
49898
49989
  return symbol;
49899
49990
  }
49900
- if (ts.getESModuleInterop(compilerOptions)) {
49901
- var referenceParent = referencingLocation.parent;
49902
- if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
49903
- ts.isImportCall(referenceParent)) {
49904
- var type = getTypeOfSymbol(symbol);
49991
+ var referenceParent = referencingLocation.parent;
49992
+ if ((ts.isImportDeclaration(referenceParent) && ts.getNamespaceDeclarationNode(referenceParent)) ||
49993
+ ts.isImportCall(referenceParent)) {
49994
+ var reference = ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier;
49995
+ var type = getTypeOfSymbol(symbol);
49996
+ var defaultOnlyType = getTypeWithSyntheticDefaultOnly(type, symbol, moduleSymbol, reference);
49997
+ if (defaultOnlyType) {
49998
+ return cloneTypeAsModuleType(symbol, defaultOnlyType, referenceParent);
49999
+ }
50000
+ if (ts.getESModuleInterop(compilerOptions)) {
49905
50001
  var sigs = getSignaturesOfStructuredType(type, 0 /* Call */);
49906
50002
  if (!sigs || !sigs.length) {
49907
50003
  sigs = getSignaturesOfStructuredType(type, 1 /* Construct */);
49908
50004
  }
49909
- if (sigs && sigs.length) {
49910
- var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, ts.isImportCall(referenceParent) ? referenceParent.arguments[0] : referenceParent.moduleSpecifier);
49911
- // Create a new symbol which has the module's type less the call and construct signatures
49912
- var result = createSymbol(symbol.flags, symbol.escapedName);
49913
- result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
49914
- result.parent = symbol.parent;
49915
- result.target = symbol;
49916
- result.originatingImport = referenceParent;
49917
- if (symbol.valueDeclaration)
49918
- result.valueDeclaration = symbol.valueDeclaration;
49919
- if (symbol.constEnumOnlyModule)
49920
- result.constEnumOnlyModule = true;
49921
- if (symbol.members)
49922
- result.members = new ts.Map(symbol.members);
49923
- if (symbol.exports)
49924
- result.exports = new ts.Map(symbol.exports);
49925
- var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
49926
- result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
49927
- return result;
50005
+ if ((sigs && sigs.length) || getPropertyOfType(type, "default" /* Default */)) {
50006
+ var moduleType = getTypeWithSyntheticDefaultImportType(type, symbol, moduleSymbol, reference);
50007
+ return cloneTypeAsModuleType(symbol, moduleType, referenceParent);
49928
50008
  }
49929
50009
  }
49930
50010
  }
49931
50011
  }
49932
50012
  return symbol;
49933
50013
  }
50014
+ /**
50015
+ * Create a new symbol which has the module's type less the call and construct signatures
50016
+ */
50017
+ function cloneTypeAsModuleType(symbol, moduleType, referenceParent) {
50018
+ var result = createSymbol(symbol.flags, symbol.escapedName);
50019
+ result.declarations = symbol.declarations ? symbol.declarations.slice() : [];
50020
+ result.parent = symbol.parent;
50021
+ result.target = symbol;
50022
+ result.originatingImport = referenceParent;
50023
+ if (symbol.valueDeclaration)
50024
+ result.valueDeclaration = symbol.valueDeclaration;
50025
+ if (symbol.constEnumOnlyModule)
50026
+ result.constEnumOnlyModule = true;
50027
+ if (symbol.members)
50028
+ result.members = new ts.Map(symbol.members);
50029
+ if (symbol.exports)
50030
+ result.exports = new ts.Map(symbol.exports);
50031
+ var resolvedModuleType = resolveStructuredTypeMembers(moduleType); // Should already be resolved from the signature checks above
50032
+ result.type = createAnonymousType(result, resolvedModuleType.members, ts.emptyArray, ts.emptyArray, resolvedModuleType.indexInfos);
50033
+ return result;
50034
+ }
49934
50035
  function hasExportAssignmentSymbol(moduleSymbol) {
49935
50036
  return moduleSymbol.exports.get("export=" /* ExportEquals */) !== undefined;
49936
50037
  }
@@ -59536,7 +59637,7 @@ var ts;
59536
59637
  var _loop_16 = function () {
59537
59638
  i--;
59538
59639
  var t = types[i];
59539
- if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeSubtypeOf(t, template); })) {
59640
+ if (t.flags & 128 /* StringLiteral */ && ts.some(templates, function (template) { return isTypeMatchedByTemplateLiteralType(t, template); })) {
59540
59641
  ts.orderedRemoveItemAt(types, i);
59541
59642
  }
59542
59643
  };
@@ -61729,7 +61830,9 @@ var ts;
61729
61830
  return mapTypeWithAlias(getReducedType(mappedTypeVariable), function (t) {
61730
61831
  if (t.flags & (3 /* AnyOrUnknown */ | 58982400 /* InstantiableNonPrimitive */ | 524288 /* Object */ | 2097152 /* Intersection */) && t !== wildcardType && !isErrorType(t)) {
61731
61832
  if (!type.declaration.nameType) {
61732
- if (isArrayType(t)) {
61833
+ var constraint = void 0;
61834
+ if (isArrayType(t) || t.flags & 1 /* Any */ && findResolutionCycleStartIndex(typeVariable, 4 /* ImmediateBaseConstraint */) < 0 &&
61835
+ (constraint = getConstraintOfTypeParameter(typeVariable)) && everyType(constraint, ts.or(isArrayType, isTupleType))) {
61733
61836
  return instantiateMappedArrayType(t, type, prependTypeMapping(typeVariable, t, mapper));
61734
61837
  }
61735
61838
  if (isGenericTupleType(t)) {
@@ -63269,13 +63372,12 @@ var ts;
63269
63372
  traceUnionsOrIntersectionsTooLarge(source, target);
63270
63373
  var result = 0 /* False */;
63271
63374
  var saveErrorInfo = captureErrorCalculationState();
63272
- // Note that these checks are specifically ordered to produce correct results. In particular,
63273
- // we need to deconstruct unions before intersections (because unions are always at the top),
63274
- // and we need to handle "each" relations before "some" relations for the same kind of type.
63275
- if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) {
63276
- result = getConstituentCount(source) * getConstituentCount(target) >= 4 ?
63277
- recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags) :
63278
- structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
63375
+ if ((source.flags & 1048576 /* Union */ || target.flags & 1048576 /* Union */) && getConstituentCount(source) * getConstituentCount(target) < 4) {
63376
+ // We skip caching when source or target is a union with no more than three constituents.
63377
+ result = structuredTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */);
63378
+ }
63379
+ else if (source.flags & 3145728 /* UnionOrIntersection */ || target.flags & 3145728 /* UnionOrIntersection */) {
63380
+ result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState | 8 /* UnionIntersectionCheck */, recursionFlags);
63279
63381
  }
63280
63382
  if (!result && !(source.flags & 1048576 /* Union */) && (source.flags & (469499904 /* StructuredOrInstantiable */) || target.flags & 469499904 /* StructuredOrInstantiable */)) {
63281
63383
  if (result = recursiveTypeRelatedTo(source, target, reportErrors, intersectionState, recursionFlags)) {
@@ -63732,19 +63834,19 @@ var ts;
63732
63834
  var maybeStart = maybeCount;
63733
63835
  maybeKeys[maybeCount] = id;
63734
63836
  maybeCount++;
63837
+ var saveExpandingFlags = expandingFlags;
63735
63838
  if (recursionFlags & 1 /* Source */) {
63736
63839
  sourceStack[sourceDepth] = source;
63737
63840
  sourceDepth++;
63841
+ if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
63842
+ expandingFlags |= 1 /* Source */;
63738
63843
  }
63739
63844
  if (recursionFlags & 2 /* Target */) {
63740
63845
  targetStack[targetDepth] = target;
63741
63846
  targetDepth++;
63847
+ if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
63848
+ expandingFlags |= 2 /* Target */;
63742
63849
  }
63743
- var saveExpandingFlags = expandingFlags;
63744
- if (!(expandingFlags & 1 /* Source */) && isDeeplyNestedType(source, sourceStack, sourceDepth))
63745
- expandingFlags |= 1 /* Source */;
63746
- if (!(expandingFlags & 2 /* Target */) && isDeeplyNestedType(target, targetStack, targetDepth))
63747
- expandingFlags |= 2 /* Target */;
63748
63850
  var originalHandler;
63749
63851
  var propagatingVarianceFlags = 0;
63750
63852
  if (outofbandVarianceMarkerHandler) {
@@ -63768,13 +63870,13 @@ var ts;
63768
63870
  if (outofbandVarianceMarkerHandler) {
63769
63871
  outofbandVarianceMarkerHandler = originalHandler;
63770
63872
  }
63771
- expandingFlags = saveExpandingFlags;
63772
63873
  if (recursionFlags & 1 /* Source */) {
63773
63874
  sourceDepth--;
63774
63875
  }
63775
63876
  if (recursionFlags & 2 /* Target */) {
63776
63877
  targetDepth--;
63777
63878
  }
63879
+ expandingFlags = saveExpandingFlags;
63778
63880
  if (result) {
63779
63881
  if (result === -1 /* True */ || (sourceDepth === 0 && targetDepth === 0)) {
63780
63882
  if (result === -1 /* True */ || result === 3 /* Maybe */) {
@@ -64112,8 +64214,7 @@ var ts;
64112
64214
  // For example, `foo-${number}` is related to `foo-${string}` even though number isn't related to string.
64113
64215
  instantiateType(source, makeFunctionTypeMapper(reportUnreliableMarkers));
64114
64216
  }
64115
- var result_9 = inferTypesFromTemplateLiteralType(source, target);
64116
- if (result_9 && ts.every(result_9, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); })) {
64217
+ if (isTypeMatchedByTemplateLiteralType(source, target)) {
64117
64218
  return -1 /* True */;
64118
64219
  }
64119
64220
  }
@@ -64308,9 +64409,9 @@ var ts;
64308
64409
  if (source.flags & (524288 /* Object */ | 2097152 /* Intersection */) && target.flags & 1048576 /* Union */) {
64309
64410
  var objectOnlyTarget = extractTypesOfKind(target, 524288 /* Object */ | 2097152 /* Intersection */ | 33554432 /* Substitution */);
64310
64411
  if (objectOnlyTarget.flags & 1048576 /* Union */) {
64311
- var result_10 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
64312
- if (result_10) {
64313
- return result_10;
64412
+ var result_9 = typeRelatedToDiscriminatedType(source, objectOnlyTarget);
64413
+ if (result_9) {
64414
+ return result_9;
64314
64415
  }
64315
64416
  }
64316
64417
  }
@@ -64382,13 +64483,13 @@ var ts;
64382
64483
  var modifiersRelated = relation === comparableRelation || (relation === identityRelation ? getMappedTypeModifiers(source) === getMappedTypeModifiers(target) :
64383
64484
  getCombinedMappedTypeOptionality(source) <= getCombinedMappedTypeOptionality(target));
64384
64485
  if (modifiersRelated) {
64385
- var result_11;
64486
+ var result_10;
64386
64487
  var targetConstraint = getConstraintTypeFromMappedType(target);
64387
64488
  var sourceConstraint = instantiateType(getConstraintTypeFromMappedType(source), makeFunctionTypeMapper(getCombinedMappedTypeOptionality(source) < 0 ? reportUnmeasurableMarkers : reportUnreliableMarkers));
64388
- if (result_11 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
64489
+ if (result_10 = isRelatedTo(targetConstraint, sourceConstraint, 3 /* Both */, reportErrors)) {
64389
64490
  var mapper = createTypeMapper([getTypeParameterFromMappedType(source)], [getTypeParameterFromMappedType(target)]);
64390
64491
  if (instantiateType(getNameTypeFromMappedType(source), mapper) === instantiateType(getNameTypeFromMappedType(target), mapper)) {
64391
- return result_11 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors);
64492
+ return result_10 & isRelatedTo(instantiateType(getTemplateTypeFromMappedType(source), mapper), getTemplateTypeFromMappedType(target), 3 /* Both */, reportErrors);
64392
64493
  }
64393
64494
  }
64394
64495
  }
@@ -66471,6 +66572,10 @@ var ts;
66471
66572
  inferFromLiteralPartsToTemplateLiteral(source.texts, source.types, target) :
66472
66573
  undefined;
66473
66574
  }
66575
+ function isTypeMatchedByTemplateLiteralType(source, target) {
66576
+ var inferences = inferTypesFromTemplateLiteralType(source, target);
66577
+ return !!inferences && ts.every(inferences, function (r, i) { return isValidTypeForTemplateLiteralPlaceholder(r, target.types[i]); });
66578
+ }
66474
66579
  function getStringLikeTypeForType(type) {
66475
66580
  return type.flags & (1 /* Any */ | 402653316 /* StringLike */) ? type : getTemplateLiteralType(["", ""], [type]);
66476
66581
  }
@@ -67374,8 +67479,11 @@ var ts;
67374
67479
  function getFlowCacheKey(node, declaredType, initialType, flowContainer) {
67375
67480
  switch (node.kind) {
67376
67481
  case 79 /* Identifier */:
67377
- var symbol = getResolvedSymbol(node);
67378
- return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined;
67482
+ if (!ts.isThisInTypeQuery(node)) {
67483
+ var symbol = getResolvedSymbol(node);
67484
+ return symbol !== unknownSymbol ? (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType) + "|" + getSymbolId(symbol) : undefined;
67485
+ }
67486
+ // falls through
67379
67487
  case 108 /* ThisKeyword */:
67380
67488
  return "0|" + (flowContainer ? getNodeId(flowContainer) : "-1") + "|" + getTypeId(declaredType) + "|" + getTypeId(initialType);
67381
67489
  case 229 /* NonNullExpression */:
@@ -68006,7 +68114,7 @@ var ts;
68006
68114
  mapType(type, mapper);
68007
68115
  }
68008
68116
  function getConstituentCount(type) {
68009
- return type.flags & 3145728 /* UnionOrIntersection */ ? type.types.length : 1;
68117
+ return type.flags & 1048576 /* Union */ ? type.types.length : 1;
68010
68118
  }
68011
68119
  function extractTypesOfKind(type, kind) {
68012
68120
  return filterType(type, function (t) { return (t.flags & kind) !== 0; });
@@ -69504,7 +69612,7 @@ var ts;
69504
69612
  return parent.kind === 205 /* PropertyAccessExpression */ ||
69505
69613
  parent.kind === 207 /* CallExpression */ && parent.expression === node ||
69506
69614
  parent.kind === 206 /* ElementAccessExpression */ && parent.expression === node &&
69507
- !(isGenericTypeWithoutNullableConstraint(type) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
69615
+ !(someType(type, isGenericTypeWithoutNullableConstraint) && isGenericIndexType(getTypeOfExpression(parent.argumentExpression)));
69508
69616
  }
69509
69617
  function isGenericTypeWithUnionConstraint(type) {
69510
69618
  return !!(type.flags & 465829888 /* Instantiable */ && getBaseConstraintOrType(type).flags & (98304 /* Nullable */ | 1048576 /* Union */));
@@ -75104,11 +75212,33 @@ var ts;
75104
75212
  if (moduleSymbol) {
75105
75213
  var esModuleSymbol = resolveESModuleSymbol(moduleSymbol, specifier, /*dontRecursivelyResolve*/ true, /*suppressUsageError*/ false);
75106
75214
  if (esModuleSymbol) {
75107
- return createPromiseReturnType(node, getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
75215
+ return createPromiseReturnType(node, getTypeWithSyntheticDefaultOnly(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier) ||
75216
+ getTypeWithSyntheticDefaultImportType(getTypeOfSymbol(esModuleSymbol), esModuleSymbol, moduleSymbol, specifier));
75108
75217
  }
75109
75218
  }
75110
75219
  return createPromiseReturnType(node, anyType);
75111
75220
  }
75221
+ function createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol) {
75222
+ var memberTable = ts.createSymbolTable();
75223
+ var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
75224
+ newSymbol.parent = originalSymbol;
75225
+ newSymbol.nameType = getStringLiteralType("default");
75226
+ newSymbol.target = resolveSymbol(symbol);
75227
+ memberTable.set("default" /* Default */, newSymbol);
75228
+ return createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
75229
+ }
75230
+ function getTypeWithSyntheticDefaultOnly(type, symbol, originalSymbol, moduleSpecifier) {
75231
+ var hasDefaultOnly = isOnlyImportedAsDefault(moduleSpecifier);
75232
+ if (hasDefaultOnly && type && !isErrorType(type)) {
75233
+ var synthType = type;
75234
+ if (!synthType.defaultOnlyType) {
75235
+ var type_4 = createDefaultPropertyWrapperForModule(symbol, originalSymbol);
75236
+ synthType.defaultOnlyType = type_4;
75237
+ }
75238
+ return synthType.defaultOnlyType;
75239
+ }
75240
+ return undefined;
75241
+ }
75112
75242
  function getTypeWithSyntheticDefaultImportType(type, symbol, originalSymbol, moduleSpecifier) {
75113
75243
  var _a;
75114
75244
  if (allowSyntheticDefaultImports && type && !isErrorType(type)) {
@@ -75117,14 +75247,8 @@ var ts;
75117
75247
  var file = (_a = originalSymbol.declarations) === null || _a === void 0 ? void 0 : _a.find(ts.isSourceFile);
75118
75248
  var hasSyntheticDefault = canHaveSyntheticDefault(file, originalSymbol, /*dontResolveAlias*/ false, moduleSpecifier);
75119
75249
  if (hasSyntheticDefault) {
75120
- var memberTable = ts.createSymbolTable();
75121
- var newSymbol = createSymbol(2097152 /* Alias */, "default" /* Default */);
75122
- newSymbol.parent = originalSymbol;
75123
- newSymbol.nameType = getStringLiteralType("default");
75124
- newSymbol.target = resolveSymbol(symbol);
75125
- memberTable.set("default" /* Default */, newSymbol);
75126
75250
  var anonymousSymbol = createSymbol(2048 /* TypeLiteral */, "__type" /* Type */);
75127
- var defaultContainingObject = createAnonymousType(anonymousSymbol, memberTable, ts.emptyArray, ts.emptyArray, ts.emptyArray);
75251
+ var defaultContainingObject = createDefaultPropertyWrapperForModule(symbol, originalSymbol, anonymousSymbol);
75128
75252
  anonymousSymbol.type = defaultContainingObject;
75129
75253
  synthType.syntheticType = isValidSpreadType(type) ? getSpreadType(type, defaultContainingObject, anonymousSymbol, /*objectFlags*/ 0, /*readonly*/ false) : defaultContainingObject;
75130
75254
  }
@@ -75832,12 +75956,12 @@ var ts;
75832
75956
  var witnesses = getSwitchClauseTypeOfWitnesses(node, /*retainDefault*/ false);
75833
75957
  // notEqualFacts states that the type of the switched value is not equal to every type in the switch.
75834
75958
  var notEqualFacts_1 = getFactsFromTypeofSwitch(0, 0, witnesses, /*hasDefault*/ true);
75835
- var type_4 = getBaseConstraintOfType(operandType) || operandType;
75959
+ var type_5 = getBaseConstraintOfType(operandType) || operandType;
75836
75960
  // Take any/unknown as a special condition. Or maybe we could change `type` to a union containing all primitive types.
75837
- if (type_4.flags & 3 /* AnyOrUnknown */) {
75961
+ if (type_5.flags & 3 /* AnyOrUnknown */) {
75838
75962
  return (556800 /* AllTypeofNE */ & notEqualFacts_1) === 556800 /* AllTypeofNE */;
75839
75963
  }
75840
- return !!(filterType(type_4, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
75964
+ return !!(filterType(type_5, function (t) { return (getTypeFacts(t) & notEqualFacts_1) === notEqualFacts_1; }).flags & 131072 /* Never */);
75841
75965
  }
75842
75966
  var type = getTypeOfExpression(node.expression);
75843
75967
  if (!isLiteralType(type)) {
@@ -78933,12 +79057,12 @@ var ts;
78933
79057
  case 264 /* ImportEqualsDeclaration */:
78934
79058
  case 267 /* NamespaceImport */:
78935
79059
  case 266 /* ImportClause */:
78936
- var result_12 = 0 /* None */;
79060
+ var result_11 = 0 /* None */;
78937
79061
  var target = resolveAlias(getSymbolOfNode(d));
78938
79062
  ts.forEach(target.declarations, function (d) {
78939
- result_12 |= getDeclarationSpaces(d);
79063
+ result_11 |= getDeclarationSpaces(d);
78940
79064
  });
78941
- return result_12;
79065
+ return result_11;
78942
79066
  case 253 /* VariableDeclaration */:
78943
79067
  case 202 /* BindingElement */:
78944
79068
  case 255 /* FunctionDeclaration */:
@@ -81807,7 +81931,7 @@ var ts;
81807
81931
  checkKindsOfPropertyMemberOverrides(type, baseType_1);
81808
81932
  }
81809
81933
  }
81810
- checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType);
81934
+ checkMembersForOverrideModifier(node, type, typeWithThis, staticType);
81811
81935
  var implementedTypeNodes = ts.getEffectiveImplementsTypeNodes(node);
81812
81936
  if (implementedTypeNodes) {
81813
81937
  for (var _b = 0, implementedTypeNodes_1 = implementedTypeNodes; _b < implementedTypeNodes_1.length; _b++) {
@@ -81842,8 +81966,7 @@ var ts;
81842
81966
  checkPropertyInitialization(node);
81843
81967
  }
81844
81968
  }
81845
- function checkMembersForMissingOverrideModifier(node, type, typeWithThis, staticType) {
81846
- var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
81969
+ function checkMembersForOverrideModifier(node, type, typeWithThis, staticType) {
81847
81970
  var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
81848
81971
  var baseTypes = baseTypeNode && getBaseTypes(type);
81849
81972
  var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
@@ -81855,46 +81978,71 @@ var ts;
81855
81978
  if (ts.isConstructorDeclaration(member)) {
81856
81979
  ts.forEach(member.parameters, function (param) {
81857
81980
  if (ts.isParameterPropertyDeclaration(param, member)) {
81858
- checkClassMember(param, /*memberIsParameterProperty*/ true);
81981
+ checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, param,
81982
+ /* memberIsParameterProperty */ true);
81859
81983
  }
81860
81984
  });
81861
81985
  }
81862
- checkClassMember(member);
81986
+ checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member,
81987
+ /* memberIsParameterProperty */ false);
81863
81988
  };
81864
81989
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
81865
81990
  var member = _a[_i];
81866
81991
  _loop_29(member);
81867
81992
  }
81868
- function checkClassMember(member, memberIsParameterProperty) {
81869
- var hasOverride = ts.hasOverrideModifier(member);
81870
- var hasStatic = ts.isStatic(member);
81871
- var isJs = ts.isInJSFile(member);
81872
- if (baseWithThis && (hasOverride || compilerOptions.noImplicitOverride)) {
81873
- var declaredProp = member.name && getSymbolAtLocation(member.name) || getSymbolAtLocation(member);
81874
- if (!declaredProp) {
81875
- return;
81876
- }
81877
- var thisType = hasStatic ? staticType : typeWithThis;
81878
- var baseType = hasStatic ? baseStaticType : baseWithThis;
81879
- var prop = getPropertyOfType(thisType, declaredProp.escapedName);
81880
- var baseProp = getPropertyOfType(baseType, declaredProp.escapedName);
81881
- var baseClassName = typeToString(baseWithThis);
81882
- if (prop && !baseProp && hasOverride) {
81883
- var suggestion = getSuggestedSymbolForNonexistentClassMember(ts.symbolName(declaredProp), baseType);
81993
+ }
81994
+ /**
81995
+ * @param member Existing member node to be checked.
81996
+ * Note: `member` cannot be a synthetic node.
81997
+ */
81998
+ function checkExistingMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, member, memberIsParameterProperty, reportErrors) {
81999
+ if (reportErrors === void 0) { reportErrors = true; }
82000
+ var declaredProp = member.name
82001
+ && getSymbolAtLocation(member.name)
82002
+ || getSymbolAtLocation(member);
82003
+ if (!declaredProp) {
82004
+ return 0 /* Ok */;
82005
+ }
82006
+ return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, ts.hasOverrideModifier(member), ts.hasAbstractModifier(member), ts.isStatic(member), memberIsParameterProperty, ts.symbolName(declaredProp), reportErrors ? member : undefined);
82007
+ }
82008
+ /**
82009
+ * Checks a class member declaration for either a missing or an invalid `override` modifier.
82010
+ * Note: this function can be used for speculative checking,
82011
+ * i.e. checking a member that does not yet exist in the program.
82012
+ * An example of that would be to call this function in a completions scenario,
82013
+ * when offering a method declaration as completion.
82014
+ * @param errorNode The node where we should report an error, or undefined if we should not report errors.
82015
+ */
82016
+ function checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, memberHasAbstractModifier, memberIsStatic, memberIsParameterProperty, memberName, errorNode) {
82017
+ var isJs = ts.isInJSFile(node);
82018
+ var nodeInAmbientContext = !!(node.flags & 8388608 /* Ambient */);
82019
+ if (baseWithThis && (memberHasOverrideModifier || compilerOptions.noImplicitOverride)) {
82020
+ var memberEscapedName = ts.escapeLeadingUnderscores(memberName);
82021
+ var thisType = memberIsStatic ? staticType : typeWithThis;
82022
+ var baseType = memberIsStatic ? baseStaticType : baseWithThis;
82023
+ var prop = getPropertyOfType(thisType, memberEscapedName);
82024
+ var baseProp = getPropertyOfType(baseType, memberEscapedName);
82025
+ var baseClassName = typeToString(baseWithThis);
82026
+ if (prop && !baseProp && memberHasOverrideModifier) {
82027
+ if (errorNode) {
82028
+ var suggestion = getSuggestedSymbolForNonexistentClassMember(memberName, baseType); // Again, using symbol name: note that's different from `symbol.escapedName`
81884
82029
  suggestion ?
81885
- error(member, isJs ?
82030
+ error(errorNode, isJs ?
81886
82031
  ts.Diagnostics.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 :
81887
82032
  ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0_Did_you_mean_1, baseClassName, symbolToString(suggestion)) :
81888
- error(member, isJs ?
82033
+ error(errorNode, isJs ?
81889
82034
  ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_it_is_not_declared_in_the_base_class_0 :
81890
82035
  ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_it_is_not_declared_in_the_base_class_0, baseClassName);
81891
82036
  }
81892
- else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) {
81893
- var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier);
81894
- if (hasOverride) {
81895
- return;
81896
- }
81897
- if (!baseHasAbstract) {
82037
+ return 2 /* HasInvalidOverride */;
82038
+ }
82039
+ else if (prop && (baseProp === null || baseProp === void 0 ? void 0 : baseProp.declarations) && compilerOptions.noImplicitOverride && !nodeInAmbientContext) {
82040
+ var baseHasAbstract = ts.some(baseProp.declarations, ts.hasAbstractModifier);
82041
+ if (memberHasOverrideModifier) {
82042
+ return 0 /* Ok */;
82043
+ }
82044
+ if (!baseHasAbstract) {
82045
+ if (errorNode) {
81898
82046
  var diag = memberIsParameterProperty ?
81899
82047
  isJs ?
81900
82048
  ts.Diagnostics.This_parameter_property_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 :
@@ -81902,20 +82050,28 @@ var ts;
81902
82050
  isJs ?
81903
82051
  ts.Diagnostics.This_member_must_have_a_JSDoc_comment_with_an_override_tag_because_it_overrides_a_member_in_the_base_class_0 :
81904
82052
  ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_a_member_in_the_base_class_0;
81905
- error(member, diag, baseClassName);
82053
+ error(errorNode, diag, baseClassName);
81906
82054
  }
81907
- else if (ts.hasAbstractModifier(member) && baseHasAbstract) {
81908
- error(member, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName);
82055
+ return 1 /* NeedsOverride */;
82056
+ }
82057
+ else if (memberHasAbstractModifier && baseHasAbstract) {
82058
+ if (errorNode) {
82059
+ error(errorNode, ts.Diagnostics.This_member_must_have_an_override_modifier_because_it_overrides_an_abstract_method_that_is_declared_in_the_base_class_0, baseClassName);
81909
82060
  }
82061
+ return 1 /* NeedsOverride */;
81910
82062
  }
81911
82063
  }
81912
- else if (hasOverride) {
82064
+ }
82065
+ else if (memberHasOverrideModifier) {
82066
+ if (errorNode) {
81913
82067
  var className = typeToString(type);
81914
- error(member, isJs ?
82068
+ error(errorNode, isJs ?
81915
82069
  ts.Diagnostics.This_member_cannot_have_a_JSDoc_comment_with_an_override_tag_because_its_containing_class_0_does_not_extend_another_class :
81916
82070
  ts.Diagnostics.This_member_cannot_have_an_override_modifier_because_its_containing_class_0_does_not_extend_another_class, className);
81917
82071
  }
82072
+ return 2 /* HasInvalidOverride */;
81918
82073
  }
82074
+ return 0 /* Ok */;
81919
82075
  }
81920
82076
  function issueMemberSpecificError(node, typeWithThis, baseWithThis, broadDiag) {
81921
82077
  // iterate over all implemented properties and issue errors on each one which isn't compatible, rather than the class as a whole, if possible
@@ -81958,6 +82114,31 @@ var ts;
81958
82114
  }
81959
82115
  }
81960
82116
  }
82117
+ /**
82118
+ * Checks a member declaration node to see if has a missing or invalid `override` modifier.
82119
+ * @param node Class-like node where the member is declared.
82120
+ * @param member Member declaration node.
82121
+ * Note: `member` can be a synthetic node without a parent.
82122
+ */
82123
+ function getMemberOverrideModifierStatus(node, member) {
82124
+ if (!member.name) {
82125
+ return 0 /* Ok */;
82126
+ }
82127
+ var symbol = getSymbolOfNode(node);
82128
+ var type = getDeclaredTypeOfSymbol(symbol);
82129
+ var typeWithThis = getTypeWithThisArgument(type);
82130
+ var staticType = getTypeOfSymbol(symbol);
82131
+ var baseTypeNode = ts.getEffectiveBaseTypeNode(node);
82132
+ var baseTypes = baseTypeNode && getBaseTypes(type);
82133
+ var baseWithThis = (baseTypes === null || baseTypes === void 0 ? void 0 : baseTypes.length) ? getTypeWithThisArgument(ts.first(baseTypes), type.thisType) : undefined;
82134
+ var baseStaticType = getBaseConstructorTypeOfClass(type);
82135
+ var memberHasOverrideModifier = member.parent
82136
+ ? ts.hasOverrideModifier(member)
82137
+ : ts.hasSyntacticModifier(member, 16384 /* Override */);
82138
+ var memberName = ts.unescapeLeadingUnderscores(ts.getTextOfPropertyName(member.name));
82139
+ return checkMemberForOverrideModifier(node, staticType, baseStaticType, baseWithThis, type, typeWithThis, memberHasOverrideModifier, ts.hasAbstractModifier(member), ts.isStatic(member),
82140
+ /* memberIsParameterProperty */ false, memberName);
82141
+ }
81961
82142
  function getTargetSymbol(s) {
81962
82143
  // if symbol is instantiated its flags are not copied from the 'target'
81963
82144
  // so we'll need to get back original 'target' symbol to work with correct set of flags
@@ -94954,11 +95135,11 @@ var ts;
94954
95135
  currentFileState.filenameDeclaration = declaration;
94955
95136
  return currentFileState.filenameDeclaration.name;
94956
95137
  }
94957
- function getJsxFactoryCalleePrimitive(childrenLength) {
94958
- return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : childrenLength > 1 ? "jsxs" : "jsx";
95138
+ function getJsxFactoryCalleePrimitive(isStaticChildren) {
95139
+ return compilerOptions.jsx === 5 /* ReactJSXDev */ ? "jsxDEV" : isStaticChildren ? "jsxs" : "jsx";
94959
95140
  }
94960
- function getJsxFactoryCallee(childrenLength) {
94961
- var type = getJsxFactoryCalleePrimitive(childrenLength);
95141
+ function getJsxFactoryCallee(isStaticChildren) {
95142
+ var type = getJsxFactoryCalleePrimitive(isStaticChildren);
94962
95143
  return getImplicitImportForName(type);
94963
95144
  }
94964
95145
  function getImplicitJsxFragmentReference() {
@@ -95110,9 +95291,9 @@ var ts;
95110
95291
  }
95111
95292
  function convertJsxChildrenToChildrenPropAssignment(children) {
95112
95293
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95113
- if (ts.length(nonWhitespaceChildren) === 1) {
95114
- var result_13 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
95115
- return result_13 && factory.createPropertyAssignment("children", result_13);
95294
+ if (ts.length(nonWhitespaceChildren) === 1 && !nonWhitespaceChildren[0].dotDotDotToken) {
95295
+ var result_12 = transformJsxChildToExpression(nonWhitespaceChildren[0]);
95296
+ return result_12 && factory.createPropertyAssignment("children", result_12);
95116
95297
  }
95117
95298
  var result = ts.mapDefined(children, transformJsxChildToExpression);
95118
95299
  return ts.length(result) ? factory.createPropertyAssignment("children", factory.createArrayLiteralExpression(result)) : undefined;
@@ -95124,15 +95305,18 @@ var ts;
95124
95305
  var attrs = keyAttr ? ts.filter(node.attributes.properties, function (p) { return p !== keyAttr; }) : node.attributes.properties;
95125
95306
  var objectProperties = ts.length(attrs) ? transformJsxAttributesToObjectProps(attrs, childrenProp) :
95126
95307
  factory.createObjectLiteralExpression(childrenProp ? [childrenProp] : ts.emptyArray); // When there are no attributes, React wants {}
95127
- return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, ts.length(ts.getSemanticJsxChildren(children || ts.emptyArray)), isChild, location);
95308
+ return visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, children || ts.emptyArray, isChild, location);
95128
95309
  }
95129
- function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, childrenLength, isChild, location) {
95310
+ function visitJsxOpeningLikeElementOrFragmentJSX(tagName, objectProperties, keyAttr, children, isChild, location) {
95311
+ var _a;
95312
+ var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95313
+ var isStaticChildren = ts.length(nonWhitespaceChildren) > 1 || !!((_a = nonWhitespaceChildren[0]) === null || _a === void 0 ? void 0 : _a.dotDotDotToken);
95130
95314
  var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)];
95131
95315
  if (compilerOptions.jsx === 5 /* ReactJSXDev */) {
95132
95316
  var originalFile = ts.getOriginalNode(currentSourceFile);
95133
95317
  if (originalFile && ts.isSourceFile(originalFile)) {
95134
95318
  // isStaticChildren development flag
95135
- args.push(childrenLength > 1 ? factory.createTrue() : factory.createFalse());
95319
+ args.push(isStaticChildren ? factory.createTrue() : factory.createFalse());
95136
95320
  // __source development flag
95137
95321
  var lineCol = ts.getLineAndCharacterOfPosition(originalFile, location.pos);
95138
95322
  args.push(factory.createObjectLiteralExpression([
@@ -95144,7 +95328,7 @@ var ts;
95144
95328
  args.push(factory.createThis());
95145
95329
  }
95146
95330
  }
95147
- var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(childrenLength), /*typeArguments*/ undefined, args), location);
95331
+ var element = ts.setTextRange(factory.createCallExpression(getJsxFactoryCallee(isStaticChildren), /*typeArguments*/ undefined, args), location);
95148
95332
  if (isChild) {
95149
95333
  ts.startOnNewLine(element);
95150
95334
  }
@@ -95174,7 +95358,7 @@ var ts;
95174
95358
  }
95175
95359
  }
95176
95360
  return visitJsxOpeningLikeElementOrFragmentJSX(getImplicitJsxFragmentReference(), childrenProps || factory.createObjectLiteralExpression([]),
95177
- /*keyAttr*/ undefined, ts.length(ts.getSemanticJsxChildren(children)), isChild, location);
95361
+ /*keyAttr*/ undefined, children, isChild, location);
95178
95362
  }
95179
95363
  function visitJsxOpeningFragmentCreateElement(node, children, isChild, location) {
95180
95364
  var element = ts.createExpressionForJsxFragment(factory, context.getEmitResolver().getJsxFactoryEntity(currentSourceFile), context.getEmitResolver().getJsxFragmentFactoryEntity(currentSourceFile), compilerOptions.reactNamespace, // TODO: GH#18217
@@ -108262,7 +108446,14 @@ var ts;
108262
108446
  // clear the parenthesizer rule as we ascend
108263
108447
  currentParenthesizerRule = undefined;
108264
108448
  }
108265
- function pipelineEmitWithHintWorker(hint, node) {
108449
+ function pipelineEmitWithHintWorker(hint, node, allowSnippets) {
108450
+ if (allowSnippets === void 0) { allowSnippets = true; }
108451
+ if (allowSnippets) {
108452
+ var snippet = ts.getSnippetElement(node);
108453
+ if (snippet) {
108454
+ return emitSnippetNode(hint, node, snippet);
108455
+ }
108456
+ }
108266
108457
  if (hint === 0 /* SourceFile */)
108267
108458
  return emitSourceFile(ts.cast(node, ts.isSourceFile));
108268
108459
  if (hint === 2 /* IdentifierName */)
@@ -108871,6 +109062,28 @@ var ts;
108871
109062
  }
108872
109063
  }
108873
109064
  //
109065
+ // Snippet Elements
109066
+ //
109067
+ function emitSnippetNode(hint, node, snippet) {
109068
+ switch (snippet.kind) {
109069
+ case 1 /* Placeholder */:
109070
+ emitPlaceholder(hint, node, snippet);
109071
+ break;
109072
+ case 0 /* TabStop */:
109073
+ emitTabStop(snippet);
109074
+ break;
109075
+ }
109076
+ }
109077
+ function emitPlaceholder(hint, node, snippet) {
109078
+ nonEscapingWrite("${" + snippet.order + ":"); // `${2:`
109079
+ pipelineEmitWithHintWorker(hint, node, /*allowSnippets*/ false); // `...`
109080
+ nonEscapingWrite("}"); // `}`
109081
+ // `${2:...}`
109082
+ }
109083
+ function emitTabStop(snippet) {
109084
+ nonEscapingWrite("$" + snippet.order);
109085
+ }
109086
+ //
108874
109087
  // Identifiers
108875
109088
  //
108876
109089
  function emitIdentifier(node) {
@@ -111109,6 +111322,15 @@ var ts;
111109
111322
  function writeProperty(s) {
111110
111323
  writer.writeProperty(s);
111111
111324
  }
111325
+ function nonEscapingWrite(s) {
111326
+ // This should be defined in a snippet-escaping text writer.
111327
+ if (writer.nonEscapingWrite) {
111328
+ writer.nonEscapingWrite(s);
111329
+ }
111330
+ else {
111331
+ writer.write(s);
111332
+ }
111333
+ }
111112
111334
  function writeLine(count) {
111113
111335
  if (count === void 0) { count = 1; }
111114
111336
  for (var i = 0; i < count; i++) {
@@ -113912,15 +114134,15 @@ var ts;
113912
114134
  // which per above occurred during the current program creation.
113913
114135
  // Since we assume the filesystem does not change during program creation,
113914
114136
  // it is safe to reuse resolutions from the earlier call.
113915
- var result_14 = [];
114137
+ var result_13 = [];
113916
114138
  var i = 0;
113917
114139
  for (var _i = 0, moduleNames_1 = moduleNames; _i < moduleNames_1.length; _i++) {
113918
114140
  var moduleName = moduleNames_1[_i];
113919
114141
  var resolvedModule = file.resolvedModules.get(moduleName, getModeForResolutionAtIndex(file, i));
113920
114142
  i++;
113921
- result_14.push(resolvedModule);
114143
+ result_13.push(resolvedModule);
113922
114144
  }
113923
- return result_14;
114145
+ return result_13;
113924
114146
  }
113925
114147
  // At this point, we know at least one of the following hold:
113926
114148
  // - file has local declarations for ambient modules
@@ -114212,8 +114434,8 @@ var ts;
114212
114434
  var typesReferenceDirectives = ts.map(newSourceFile.typeReferenceDirectives, function (ref) { return ts.toFileNameLowerCase(ref.fileName); });
114213
114435
  var typeReferenceResolutions = resolveTypeReferenceDirectiveNamesWorker(typesReferenceDirectives, newSourceFile);
114214
114436
  // ensure that types resolutions are still correct
114215
- var typeReferenceEesolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
114216
- if (typeReferenceEesolutionsChanged) {
114437
+ var typeReferenceResolutionsChanged = ts.hasChangesInResolutions(typesReferenceDirectives, typeReferenceResolutions, oldSourceFile.resolvedTypeReferenceDirectiveNames, oldSourceFile, ts.typeDirectiveIsEqualTo);
114438
+ if (typeReferenceResolutionsChanged) {
114217
114439
  structureIsReused = 1 /* SafeModules */;
114218
114440
  newSourceFile.resolvedTypeReferenceDirectiveNames = ts.zipToModeAwareCache(newSourceFile, typesReferenceDirectives, typeReferenceResolutions);
114219
114441
  }
@@ -115501,6 +115723,21 @@ var ts;
115501
115723
  return resolvedRef;
115502
115724
  }
115503
115725
  function verifyCompilerOptions() {
115726
+ var isNightly = ts.stringContains(ts.version, "-dev");
115727
+ if (!isNightly) {
115728
+ if (ts.getEmitModuleKind(options) === ts.ModuleKind.Node12) {
115729
+ 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");
115730
+ }
115731
+ else if (ts.getEmitModuleKind(options) === ts.ModuleKind.NodeNext) {
115732
+ 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");
115733
+ }
115734
+ else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12) {
115735
+ 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");
115736
+ }
115737
+ else if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
115738
+ 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");
115739
+ }
115740
+ }
115504
115741
  if (options.strictPropertyInitialization && !ts.getStrictOptionValue(options, "strictNullChecks")) {
115505
115742
  createDiagnosticForOptionName(ts.Diagnostics.Option_0_cannot_be_specified_without_specifying_option_1, "strictPropertyInitialization", "strictNullChecks");
115506
115743
  }
@@ -115649,7 +115886,9 @@ var ts;
115649
115886
  }
115650
115887
  }
115651
115888
  if (options.resolveJsonModule) {
115652
- if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs) {
115889
+ if (ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeJs &&
115890
+ ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.Node12 &&
115891
+ ts.getEmitModuleResolutionKind(options) !== ts.ModuleResolutionKind.NodeNext) {
115653
115892
  createDiagnosticForOptionName(ts.Diagnostics.Option_resolveJsonModule_cannot_be_specified_without_node_module_resolution_strategy, "resolveJsonModule");
115654
115893
  }
115655
115894
  // Any emit other than common js, amd, es2015 or esnext is error
@@ -115977,8 +116216,8 @@ var ts;
115977
116216
  function createDiagnosticForOptionName(message, option1, option2, option3) {
115978
116217
  createDiagnosticForOption(/*onKey*/ true, option1, option2, message, option1, option2, option3);
115979
116218
  }
115980
- function createOptionValueDiagnostic(option1, message, arg0) {
115981
- createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0);
116219
+ function createOptionValueDiagnostic(option1, message, arg0, arg1) {
116220
+ createDiagnosticForOption(/*onKey*/ false, option1, /*option2*/ undefined, message, arg0, arg1);
115982
116221
  }
115983
116222
  function createDiagnosticForReference(sourceFile, index, message, arg0, arg1) {
115984
116223
  var referencesSyntax = ts.firstDefined(ts.getTsConfigPropArray(sourceFile || options.configFile, "references"), function (property) { return ts.isArrayLiteralExpression(property.initializer) ? property.initializer : undefined; });
@@ -118222,6 +118461,9 @@ var ts;
118222
118461
  else {
118223
118462
  resolution = loader(name, containingFile, compilerOptions, ((_c = resolutionHost.getCompilerHost) === null || _c === void 0 ? void 0 : _c.call(resolutionHost)) || resolutionHost, redirectedReference, containingSourceFile);
118224
118463
  perDirectoryResolution.set(name, mode, resolution);
118464
+ if (resolutionHost.onDiscoveredSymlink && resolutionIsSymlink(resolution)) {
118465
+ resolutionHost.onDiscoveredSymlink();
118466
+ }
118225
118467
  }
118226
118468
  resolutionsInFile.set(name, mode, resolution);
118227
118469
  watchFailedLookupLocationsOfExternalModuleResolutions(name, resolution, path, getResolutionWithResolvedFileName);
@@ -118690,6 +118932,11 @@ var ts;
118690
118932
  }
118691
118933
  }
118692
118934
  ts.createResolutionCache = createResolutionCache;
118935
+ function resolutionIsSymlink(resolution) {
118936
+ var _a, _b;
118937
+ return !!(((_a = resolution.resolvedModule) === null || _a === void 0 ? void 0 : _a.originalPath) ||
118938
+ ((_b = resolution.resolvedTypeReferenceDirective) === null || _b === void 0 ? void 0 : _b.originalPath));
118939
+ }
118693
118940
  })(ts || (ts = {}));
118694
118941
  // Used by importFixes, getEditsForFileRename, and declaration emit to synthesize import module specifiers.
118695
118942
  /* @internal */
@@ -118982,9 +119229,9 @@ var ts;
118982
119229
  if (!preferSymlinks) {
118983
119230
  // Symlinks inside ignored paths are already filtered out of the symlink cache,
118984
119231
  // so we only need to remove them from the realpath filenames.
118985
- var result_15 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
118986
- if (result_15)
118987
- return result_15;
119232
+ var result_14 = ts.forEach(targets, function (p) { return !(shouldFilterIgnoredPaths && ts.containsIgnoredPath(p)) && cb(p, referenceRedirect === p); });
119233
+ if (result_14)
119234
+ return result_14;
118988
119235
  }
118989
119236
  var symlinkedDirectories = (_a = host.getSymlinkCache) === null || _a === void 0 ? void 0 : _a.call(host).getSymlinkedDirectoriesByRealpath();
118990
119237
  var fullImportedFileName = ts.getNormalizedAbsolutePath(importedFileName, cwd);
@@ -119004,10 +119251,10 @@ var ts;
119004
119251
  for (var _i = 0, symlinkDirectories_1 = symlinkDirectories; _i < symlinkDirectories_1.length; _i++) {
119005
119252
  var symlinkDirectory = symlinkDirectories_1[_i];
119006
119253
  var option = ts.resolvePath(symlinkDirectory, relative);
119007
- var result_16 = cb(option, target === referenceRedirect);
119254
+ var result_15 = cb(option, target === referenceRedirect);
119008
119255
  shouldFilterIgnoredPaths = true; // We found a non-ignored path in symlinks, so we can reject ignored-path realpaths
119009
- if (result_16)
119010
- return result_16;
119256
+ if (result_15)
119257
+ return result_15;
119011
119258
  }
119012
119259
  });
119013
119260
  });
@@ -126132,6 +126379,16 @@ var ts;
126132
126379
  return decisionFromFile !== null && decisionFromFile !== void 0 ? decisionFromFile : program.usesUriStyleNodeCoreModules;
126133
126380
  }
126134
126381
  ts.shouldUseUriStyleNodeCoreModules = shouldUseUriStyleNodeCoreModules;
126382
+ function getNewLineKind(newLineCharacter) {
126383
+ return newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */;
126384
+ }
126385
+ ts.getNewLineKind = getNewLineKind;
126386
+ function diagnosticToString(diag) {
126387
+ return ts.isArray(diag)
126388
+ ? ts.formatStringFromArgs(ts.getLocaleSpecificMessage(diag[0]), diag.slice(1))
126389
+ : ts.getLocaleSpecificMessage(diag);
126390
+ }
126391
+ ts.diagnosticToString = diagnosticToString;
126135
126392
  // #endregion
126136
126393
  })(ts || (ts = {}));
126137
126394
  /*@internal*/
@@ -127729,7 +127986,7 @@ var ts;
127729
127986
  (function (Completions) {
127730
127987
  var StringCompletions;
127731
127988
  (function (StringCompletions) {
127732
- function getStringLiteralCompletions(sourceFile, position, contextToken, checker, options, host, log, preferences) {
127989
+ function getStringLiteralCompletions(sourceFile, position, contextToken, options, host, program, log, preferences) {
127733
127990
  if (ts.isInReferenceComment(sourceFile, position)) {
127734
127991
  var entries = getTripleSlashReferenceCompletion(sourceFile, position, options, host);
127735
127992
  return entries && convertPathCompletions(entries);
@@ -127737,12 +127994,12 @@ var ts;
127737
127994
  if (ts.isInString(sourceFile, position, contextToken)) {
127738
127995
  if (!contextToken || !ts.isStringLiteralLike(contextToken))
127739
127996
  return undefined;
127740
- var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, checker, options, host, preferences);
127741
- return convertStringLiteralCompletions(entries, contextToken, sourceFile, checker, log, options, preferences);
127997
+ var entries = getStringLiteralCompletionEntries(sourceFile, contextToken, position, program.getTypeChecker(), options, host, preferences);
127998
+ return convertStringLiteralCompletions(entries, contextToken, sourceFile, host, program, log, options, preferences);
127742
127999
  }
127743
128000
  }
127744
128001
  StringCompletions.getStringLiteralCompletions = getStringLiteralCompletions;
127745
- function convertStringLiteralCompletions(completion, contextToken, sourceFile, checker, log, options, preferences) {
128002
+ function convertStringLiteralCompletions(completion, contextToken, sourceFile, host, program, log, options, preferences) {
127746
128003
  if (completion === undefined) {
127747
128004
  return undefined;
127748
128005
  }
@@ -127752,7 +128009,7 @@ var ts;
127752
128009
  return convertPathCompletions(completion.paths);
127753
128010
  case 1 /* Properties */: {
127754
128011
  var entries = [];
127755
- Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, checker, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary
128012
+ Completions.getCompletionEntriesFromSymbols(completion.symbols, entries, contextToken, contextToken, sourceFile, sourceFile, host, program, 99 /* ESNext */, log, 4 /* String */, preferences, options); // Target will not be used, so arbitrary
127756
128013
  return { isGlobalCompletion: false, isMemberCompletion: true, isNewIdentifierLocation: completion.hasIndexSignature, optionalReplacementSpan: optionalReplacementSpan, entries: entries };
127757
128014
  }
127758
128015
  case 2 /* Types */: {
@@ -128478,6 +128735,8 @@ var ts;
128478
128735
  (function (CompletionSource) {
128479
128736
  /** Completions that require `this.` insertion text */
128480
128737
  CompletionSource["ThisProperty"] = "ThisProperty/";
128738
+ /** Auto-import that comes attached to a class member snippet */
128739
+ CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
128481
128740
  })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
128482
128741
  var SymbolOriginInfoKind;
128483
128742
  (function (SymbolOriginInfoKind) {
@@ -128586,7 +128845,6 @@ var ts;
128586
128845
  }
128587
128846
  // If the request is a continuation of an earlier `isIncomplete` response,
128588
128847
  // we can continue it from the cached previous response.
128589
- var typeChecker = program.getTypeChecker();
128590
128848
  var compilerOptions = program.getCompilerOptions();
128591
128849
  var incompleteCompletionsCache = preferences.allowIncompleteCompletions ? (_a = host.getIncompleteCompletionsCache) === null || _a === void 0 ? void 0 : _a.call(host) : undefined;
128592
128850
  if (incompleteCompletionsCache && completionKind === 3 /* TriggerForIncompleteCompletions */ && previousToken && ts.isIdentifier(previousToken)) {
@@ -128598,7 +128856,7 @@ var ts;
128598
128856
  else {
128599
128857
  incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.clear();
128600
128858
  }
128601
- var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken, typeChecker, compilerOptions, host, log, preferences);
128859
+ var stringCompletions = Completions.StringCompletions.getStringLiteralCompletions(sourceFile, position, previousToken, compilerOptions, host, program, log, preferences);
128602
128860
  if (stringCompletions) {
128603
128861
  return stringCompletions;
128604
128862
  }
@@ -128612,7 +128870,7 @@ var ts;
128612
128870
  }
128613
128871
  switch (completionData.kind) {
128614
128872
  case 0 /* Data */:
128615
- var response = completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences);
128873
+ var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences);
128616
128874
  if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
128617
128875
  incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
128618
128876
  }
@@ -128709,7 +128967,7 @@ var ts;
128709
128967
  // StringLiteralLike locations are handled separately in stringCompletions.ts
128710
128968
  return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
128711
128969
  }
128712
- function completionInfoFromData(sourceFile, typeChecker, compilerOptions, log, completionData, preferences) {
128970
+ function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences) {
128713
128971
  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;
128714
128972
  // Verify if the file is JSX language variant
128715
128973
  if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
@@ -128721,7 +128979,7 @@ var ts;
128721
128979
  var entries = [];
128722
128980
  if (isUncheckedFile(sourceFile, compilerOptions)) {
128723
128981
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
128724
- /*replacementToken*/ undefined, contextToken, location, sourceFile, typeChecker, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
128982
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
128725
128983
  getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
128726
128984
  }
128727
128985
  else {
@@ -128729,7 +128987,7 @@ var ts;
128729
128987
  return undefined;
128730
128988
  }
128731
128989
  getCompletionEntriesFromSymbols(symbols, entries,
128732
- /*replacementToken*/ undefined, contextToken, location, sourceFile, typeChecker, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
128990
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap);
128733
128991
  }
128734
128992
  if (keywordFilters !== 0 /* None */) {
128735
128993
  var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
@@ -128835,14 +129093,16 @@ var ts;
128835
129093
  function createCompletionEntryForLiteral(sourceFile, preferences, literal) {
128836
129094
  return { name: completionNameForLiteral(sourceFile, preferences, literal), kind: "string" /* string */, kindModifiers: "" /* none */, sortText: SortText.LocationPriority };
128837
129095
  }
128838
- function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences) {
128839
- var _a;
129096
+ function createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, options, preferences, completionKind) {
129097
+ var _a, _b;
128840
129098
  var insertText;
128841
129099
  var replacementSpan = ts.getReplacementSpanForContextToken(replacementToken);
128842
129100
  var data;
128843
129101
  var isSnippet;
129102
+ var source = getSourceFromOrigin(origin);
128844
129103
  var sourceDisplay;
128845
129104
  var hasAction;
129105
+ var typeChecker = program.getTypeChecker();
128846
129106
  var insertQuestionDot = origin && originIsNullableMember(origin);
128847
129107
  var useBraces = origin && originIsSymbolMember(origin) || needsConvertPropertyAccess;
128848
129108
  if (origin && originIsThisType(origin)) {
@@ -128893,12 +129153,16 @@ var ts;
128893
129153
  isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
128894
129154
  }
128895
129155
  }
128896
- if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) {
128897
- return undefined;
128898
- }
128899
- if (originIsExport(origin) || originIsResolvedExport(origin)) {
128900
- data = originToCompletionEntryData(origin);
128901
- hasAction = !importCompletionNode;
129156
+ if (preferences.includeCompletionsWithClassMemberSnippets &&
129157
+ preferences.includeCompletionsWithInsertText &&
129158
+ completionKind === 3 /* MemberLike */ &&
129159
+ isClassLikeMemberCompletion(symbol, location)) {
129160
+ var importAdder = void 0;
129161
+ (_b = getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken), insertText = _b.insertText, isSnippet = _b.isSnippet, importAdder = _b.importAdder);
129162
+ if (importAdder === null || importAdder === void 0 ? void 0 : importAdder.hasFixes()) {
129163
+ hasAction = true;
129164
+ source = CompletionSource.ClassMemberSnippet;
129165
+ }
128902
129166
  }
128903
129167
  var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, location);
128904
129168
  if (kind === "JSX attribute" /* jsxAttribute */ && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
@@ -128910,7 +129174,7 @@ var ts;
128910
129174
  && !(type.flags & 1048576 /* Union */ && ts.find(type.types, function (type) { return !!(type.flags & 528 /* BooleanLike */); }))) {
128911
129175
  if (type.flags & 402653316 /* StringLike */ || (type.flags & 1048576 /* Union */ && ts.every(type.types, function (type) { return !!(type.flags & (402653316 /* StringLike */ | 32768 /* Undefined */)); }))) {
128912
129176
  // If is string like or undefined use quotes
128913
- insertText = escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1");
129177
+ insertText = ts.escapeSnippetText(name) + "=" + ts.quote(sourceFile, preferences, "$1");
128914
129178
  isSnippet = true;
128915
129179
  }
128916
129180
  else {
@@ -128919,13 +129183,20 @@ var ts;
128919
129183
  }
128920
129184
  }
128921
129185
  if (useBraces_1) {
128922
- insertText = escapeSnippetText(name) + "={$1}";
129186
+ insertText = ts.escapeSnippetText(name) + "={$1}";
128923
129187
  isSnippet = true;
128924
129188
  }
128925
129189
  if (isSnippet) {
128926
129190
  replacementSpan = ts.createTextSpanFromNode(location, sourceFile);
128927
129191
  }
128928
129192
  }
129193
+ if (insertText !== undefined && !preferences.includeCompletionsWithInsertText) {
129194
+ return undefined;
129195
+ }
129196
+ if (originIsExport(origin) || originIsResolvedExport(origin)) {
129197
+ data = originToCompletionEntryData(origin);
129198
+ hasAction = !importCompletionNode;
129199
+ }
128929
129200
  // TODO(drosen): Right now we just permit *all* semantic meanings when calling
128930
129201
  // 'getSymbolKind' which is permissible given that it is backwards compatible; but
128931
129202
  // really we should consider passing the meaning for the node so that we don't report
@@ -128938,7 +129209,7 @@ var ts;
128938
129209
  kind: kind,
128939
129210
  kindModifiers: ts.SymbolDisplay.getSymbolModifiers(typeChecker, symbol),
128940
129211
  sortText: sortText,
128941
- source: getSourceFromOrigin(origin),
129212
+ source: source,
128942
129213
  hasAction: hasAction ? true : undefined,
128943
129214
  isRecommended: isRecommendedCompletionMatch(symbol, recommendedCompletion, typeChecker) || undefined,
128944
129215
  insertText: insertText,
@@ -128950,8 +129221,172 @@ var ts;
128950
129221
  data: data,
128951
129222
  };
128952
129223
  }
128953
- function escapeSnippetText(text) {
128954
- return text.replace(/\$/gm, "\\$");
129224
+ function isClassLikeMemberCompletion(symbol, location) {
129225
+ // TODO: support JS files.
129226
+ if (ts.isInJSFile(location)) {
129227
+ return false;
129228
+ }
129229
+ // Completion symbol must be for a class member.
129230
+ var memberFlags = 106500 /* ClassMember */
129231
+ & 900095 /* EnumMemberExcludes */;
129232
+ /* In
129233
+ `class C {
129234
+ |
129235
+ }`
129236
+ `location` is a class-like declaration.
129237
+ In
129238
+ `class C {
129239
+ m|
129240
+ }`
129241
+ `location` is an identifier,
129242
+ `location.parent` is a class element declaration,
129243
+ and `location.parent.parent` is a class-like declaration.
129244
+ In
129245
+ `abstract class C {
129246
+ abstract
129247
+ abstract m|
129248
+ }`
129249
+ `location` is a syntax list (with modifiers as children),
129250
+ and `location.parent` is a class-like declaration.
129251
+ */
129252
+ return !!(symbol.flags & memberFlags) &&
129253
+ (ts.isClassLike(location) ||
129254
+ (location.parent &&
129255
+ location.parent.parent &&
129256
+ ts.isClassElement(location.parent) &&
129257
+ location === location.parent.name &&
129258
+ ts.isClassLike(location.parent.parent)) ||
129259
+ (location.parent &&
129260
+ ts.isSyntaxList(location) &&
129261
+ ts.isClassLike(location.parent)));
129262
+ }
129263
+ function getEntryForMemberCompletion(host, program, options, preferences, name, symbol, location, contextToken) {
129264
+ var classLikeDeclaration = ts.findAncestor(location, ts.isClassLike);
129265
+ if (!classLikeDeclaration) {
129266
+ return { insertText: name };
129267
+ }
129268
+ var isSnippet;
129269
+ var insertText = name;
129270
+ var checker = program.getTypeChecker();
129271
+ var sourceFile = location.getSourceFile();
129272
+ var printer = createSnippetPrinter({
129273
+ removeComments: true,
129274
+ module: options.module,
129275
+ target: options.target,
129276
+ omitTrailingSemicolon: true,
129277
+ newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
129278
+ });
129279
+ var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
129280
+ var body;
129281
+ if (preferences.includeCompletionsWithSnippetText) {
129282
+ isSnippet = true;
129283
+ // We are adding a tabstop (i.e. `$0`) in the body of the suggested member,
129284
+ // if it has one, so that the cursor ends up in the body once the completion is inserted.
129285
+ // Note: this assumes we won't have more than one body in the completion nodes, which should be the case.
129286
+ var emptyStatement = ts.factory.createExpressionStatement(ts.factory.createIdentifier(""));
129287
+ ts.setSnippetElement(emptyStatement, { kind: 0 /* TabStop */, order: 0 });
129288
+ body = ts.factory.createBlock([emptyStatement], /* multiline */ true);
129289
+ }
129290
+ else {
129291
+ body = ts.factory.createBlock([], /* multiline */ true);
129292
+ }
129293
+ var modifiers = 0 /* None */;
129294
+ // Whether the suggested member should be abstract.
129295
+ // e.g. in `abstract class C { abstract | }`, we should offer abstract method signatures at position `|`.
129296
+ // Note: We are relying on checking if the context token is `abstract`,
129297
+ // since other visibility modifiers (e.g. `protected`) should come *before* `abstract`.
129298
+ // However, that is not true for the e.g. `override` modifier, so this check has its limitations.
129299
+ var isAbstract = contextToken && isModifierLike(contextToken) === 126 /* AbstractKeyword */;
129300
+ var completionNodes = [];
129301
+ ts.codefix.addNewNodeForMemberSymbol(symbol, classLikeDeclaration, sourceFile, { program: program, host: host }, preferences, importAdder,
129302
+ // `addNewNodeForMemberSymbol` calls this callback function for each new member node
129303
+ // it adds for the given member symbol.
129304
+ // We store these member nodes in the `completionNodes` array.
129305
+ // Note: there might be:
129306
+ // - No nodes if `addNewNodeForMemberSymbol` cannot figure out a node for the member;
129307
+ // - One node;
129308
+ // - More than one node if the member is overloaded (e.g. a method with overload signatures).
129309
+ function (node) {
129310
+ var requiredModifiers = 0 /* None */;
129311
+ if (isAbstract) {
129312
+ requiredModifiers |= 128 /* Abstract */;
129313
+ }
129314
+ if (ts.isClassElement(node)
129315
+ && checker.getMemberOverrideModifierStatus(classLikeDeclaration, node) === 1 /* NeedsOverride */) {
129316
+ requiredModifiers |= 16384 /* Override */;
129317
+ }
129318
+ var presentModifiers = 0 /* None */;
129319
+ if (!completionNodes.length) {
129320
+ // Omit already present modifiers from the first completion node/signature.
129321
+ if (contextToken) {
129322
+ presentModifiers = getPresentModifiers(contextToken);
129323
+ }
129324
+ // Keep track of added missing required modifiers and modifiers already present.
129325
+ // This is needed when we have overloaded signatures,
129326
+ // so this callback will be called for multiple nodes/signatures,
129327
+ // and we need to make sure the modifiers are uniform for all nodes/signatures.
129328
+ modifiers = node.modifierFlagsCache | requiredModifiers | presentModifiers;
129329
+ }
129330
+ node = ts.factory.updateModifiers(node, modifiers & (~presentModifiers));
129331
+ completionNodes.push(node);
129332
+ }, body, isAbstract);
129333
+ if (completionNodes.length) {
129334
+ insertText = printer.printSnippetList(1 /* MultiLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
129335
+ }
129336
+ return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder };
129337
+ }
129338
+ function getPresentModifiers(contextToken) {
129339
+ var modifiers = 0 /* None */;
129340
+ var contextMod;
129341
+ /*
129342
+ Cases supported:
129343
+ In
129344
+ `class C {
129345
+ public abstract |
129346
+ }`
129347
+ `contextToken` is ``abstract`` (as an identifier),
129348
+ `contextToken.parent` is property declaration,
129349
+ `location` is class declaration ``class C { ... }``.
129350
+ In
129351
+ `class C {
129352
+ protected override m|
129353
+ }`
129354
+ `contextToken` is ``override`` (as a keyword),
129355
+ `contextToken.parent` is property declaration,
129356
+ `location` is identifier ``m``,
129357
+ `location.parent` is property declaration ``protected override m``,
129358
+ `location.parent.parent` is class declaration ``class C { ... }``.
129359
+ */
129360
+ if (contextMod = isModifierLike(contextToken)) {
129361
+ modifiers |= ts.modifierToFlag(contextMod);
129362
+ }
129363
+ if (ts.isPropertyDeclaration(contextToken.parent)) {
129364
+ modifiers |= ts.modifiersToFlags(contextToken.parent.modifiers);
129365
+ }
129366
+ return modifiers;
129367
+ }
129368
+ function isModifierLike(node) {
129369
+ if (ts.isModifier(node)) {
129370
+ return node.kind;
129371
+ }
129372
+ if (ts.isIdentifier(node) && node.originalKeywordKind && ts.isModifierKind(node.originalKeywordKind)) {
129373
+ return node.originalKeywordKind;
129374
+ }
129375
+ return undefined;
129376
+ }
129377
+ function createSnippetPrinter(printerOptions) {
129378
+ var printer = ts.createPrinter(printerOptions);
129379
+ var baseWriter = ts.createTextWriter(ts.getNewLineCharacter(printerOptions));
129380
+ var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(ts.escapeSnippetText(s)); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return baseWriter.writeLiteral(ts.escapeSnippetText(s)); }, writeStringLiteral: function (s) { return baseWriter.writeStringLiteral(ts.escapeSnippetText(s)); }, writeSymbol: function (s, symbol) { return baseWriter.writeSymbol(ts.escapeSnippetText(s), symbol); }, writeParameter: function (s) { return baseWriter.writeParameter(ts.escapeSnippetText(s)); }, writeComment: function (s) { return baseWriter.writeComment(ts.escapeSnippetText(s)); }, writeProperty: function (s) { return baseWriter.writeProperty(ts.escapeSnippetText(s)); } });
129381
+ return {
129382
+ printSnippetList: printSnippetList,
129383
+ };
129384
+ /* Snippet-escaping version of `printer.printList`. */
129385
+ function printSnippetList(format, list, sourceFile) {
129386
+ writer.clear();
129387
+ printer.writeList(format, list, sourceFile, writer);
129388
+ return writer.getText();
129389
+ }
128955
129390
  }
128956
129391
  function originToCompletionEntryData(origin) {
128957
129392
  var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
@@ -129019,10 +129454,10 @@ var ts;
129019
129454
  var importSpecifierTypeOnlyText = isImportSpecifierTypeOnly ? ts.tokenToString(151 /* TypeKeyword */) + " " : "";
129020
129455
  var suffix = useSemicolons ? ";" : "";
129021
129456
  switch (importKind) {
129022
- case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
129023
- case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
129024
- case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
129025
- case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
129457
+ case 3 /* CommonJS */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " = require(" + quotedModuleSpecifier + ")" + suffix };
129458
+ case 1 /* Default */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " from " + quotedModuleSpecifier + suffix };
129459
+ case 2 /* Namespace */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "* as " + ts.escapeSnippetText(name) + " from " + quotedModuleSpecifier + suffix };
129460
+ case 0 /* Named */: return { replacementSpan: replacementSpan, insertText: "import" + topLevelTypeOnlyText + "{ " + importSpecifierTypeOnlyText + ts.escapeSnippetText(name) + tabStop + " } from " + quotedModuleSpecifier + suffix };
129026
129461
  }
129027
129462
  }
129028
129463
  function quotePropertyName(sourceFile, preferences, name) {
@@ -129046,11 +129481,12 @@ var ts;
129046
129481
  return CompletionSource.ThisProperty;
129047
129482
  }
129048
129483
  }
129049
- function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, typeChecker, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
129484
+ function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap) {
129050
129485
  var _a;
129051
129486
  var start = ts.timestamp();
129052
129487
  var variableDeclaration = getVariableDeclaration(location);
129053
129488
  var useSemicolons = ts.probablyUsesSemicolons(sourceFile);
129489
+ var typeChecker = program.getTypeChecker();
129054
129490
  // Tracks unique names.
129055
129491
  // Value is set to false for global variables or completions from external module exports, because we can have multiple of those;
129056
129492
  // true otherwise. Based on the order we add things we will always see locals first, then globals, then module exports.
@@ -129066,7 +129502,7 @@ var ts;
129066
129502
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
129067
129503
  var sortTextId = (_a = symbolToSortTextIdMap === null || symbolToSortTextIdMap === void 0 ? void 0 : symbolToSortTextIdMap[ts.getSymbolId(symbol)]) !== null && _a !== void 0 ? _a : 11 /* LocationPriority */;
129068
129504
  var sortText = (isDeprecated(symbol, typeChecker) ? 8 /* DeprecatedOffset */ + sortTextId : sortTextId).toString();
129069
- var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, typeChecker, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences);
129505
+ var entry = createCompletionEntry(symbol, sortText, replacementToken, contextToken, location, sourceFile, host, program, name, needsConvertPropertyAccess, origin, recommendedCompletion, propertyAccessToConvert, isJsxInitializer, importCompletionNode, useSemicolons, compilerOptions, preferences, kind);
129070
129506
  if (!entry) {
129071
129507
  continue;
129072
129508
  }
@@ -129159,11 +129595,13 @@ var ts;
129159
129595
  if (entryId.data) {
129160
129596
  var autoImport = getAutoImportSymbolFromCompletionEntryData(entryId.name, entryId.data, program, host);
129161
129597
  if (autoImport) {
129598
+ var _a = getRelevantTokens(position, sourceFile), contextToken_1 = _a.contextToken, previousToken_1 = _a.previousToken;
129162
129599
  return {
129163
129600
  type: "symbol",
129164
129601
  symbol: autoImport.symbol,
129165
129602
  location: ts.getTouchingPropertyName(sourceFile, position),
129166
- previousToken: ts.findPrecedingToken(position, sourceFile, /*startNode*/ undefined),
129603
+ previousToken: previousToken_1,
129604
+ contextToken: contextToken_1,
129167
129605
  isJsxInitializer: false,
129168
129606
  isTypeOnlyLocation: false,
129169
129607
  origin: autoImport.origin,
@@ -129178,7 +129616,7 @@ var ts;
129178
129616
  if (completionData.kind !== 0 /* Data */) {
129179
129617
  return { type: "request", request: completionData };
129180
129618
  }
129181
- 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;
129619
+ 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;
129182
129620
  var literal = ts.find(literals, function (l) { return completionNameForLiteral(sourceFile, preferences, l) === entryId.name; });
129183
129621
  if (literal !== undefined)
129184
129622
  return { type: "literal", literal: literal };
@@ -129189,15 +129627,15 @@ var ts;
129189
129627
  return ts.firstDefined(symbols, function (symbol, index) {
129190
129628
  var origin = symbolToOriginInfoMap[index];
129191
129629
  var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
129192
- return info && info.name === entryId.name && getSourceFromOrigin(origin) === entryId.source
129193
- ? { type: "symbol", symbol: symbol, location: location, origin: origin, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
129630
+ return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ || getSourceFromOrigin(origin) === entryId.source)
129631
+ ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
129194
129632
  : undefined;
129195
129633
  }) || { type: "none" };
129196
129634
  }
129197
129635
  function getCompletionEntryDetails(program, log, sourceFile, position, entryId, host, formatContext, preferences, cancellationToken) {
129198
129636
  var typeChecker = program.getTypeChecker();
129199
129637
  var compilerOptions = program.getCompilerOptions();
129200
- var name = entryId.name;
129638
+ var name = entryId.name, source = entryId.source, data = entryId.data;
129201
129639
  var contextToken = ts.findPrecedingToken(position, sourceFile);
129202
129640
  if (ts.isInString(sourceFile, position, contextToken)) {
129203
129641
  return Completions.StringCompletions.getStringLiteralCompletionDetails(name, sourceFile, position, contextToken, typeChecker, compilerOptions, host, cancellationToken, preferences);
@@ -129221,8 +129659,8 @@ var ts;
129221
129659
  }
129222
129660
  }
129223
129661
  case "symbol": {
129224
- var symbol = symbolCompletion.symbol, location = symbolCompletion.location, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken;
129225
- var _a = getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, entryId.data), codeActions = _a.codeActions, sourceDisplay = _a.sourceDisplay;
129662
+ var symbol = symbolCompletion.symbol, location = symbolCompletion.location, contextToken_2 = symbolCompletion.contextToken, origin = symbolCompletion.origin, previousToken = symbolCompletion.previousToken;
129663
+ 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;
129226
129664
  return createCompletionDetailsForSymbol(symbol, typeChecker, sourceFile, location, cancellationToken, codeActions, sourceDisplay); // TODO: GH#18217
129227
129665
  }
129228
129666
  case "literal": {
@@ -129251,14 +129689,27 @@ var ts;
129251
129689
  return { name: name, kindModifiers: kindModifiers, kind: kind, displayParts: displayParts, documentation: documentation, tags: tags, codeActions: codeActions, source: source, sourceDisplay: source };
129252
129690
  }
129253
129691
  Completions.createCompletionDetails = createCompletionDetails;
129254
- function getCompletionEntryCodeActionsAndSourceDisplay(origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data) {
129692
+ function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source) {
129255
129693
  if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
129256
- var _a = getRelevantTokens(position, sourceFile), contextToken = _a.contextToken, previousToken_1 = _a.previousToken;
129257
- if (previousToken_1 && getImportStatementCompletionInfo(contextToken || previousToken_1).replacementNode) {
129694
+ var _a = getRelevantTokens(position, sourceFile), contextToken_3 = _a.contextToken, previousToken_2 = _a.previousToken;
129695
+ if (previousToken_2 && getImportStatementCompletionInfo(contextToken_3 || previousToken_2).replacementNode) {
129258
129696
  // Import statement completion: 'import c|'
129259
129697
  return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
129260
129698
  }
129261
129699
  }
129700
+ if (source === CompletionSource.ClassMemberSnippet) {
129701
+ var importAdder = getEntryForMemberCompletion(host, program, compilerOptions, preferences, name, symbol, location, contextToken).importAdder;
129702
+ if (importAdder) {
129703
+ var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
129704
+ return {
129705
+ sourceDisplay: undefined,
129706
+ codeActions: [{
129707
+ changes: changes,
129708
+ description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
129709
+ }],
129710
+ };
129711
+ }
129712
+ }
129262
129713
  if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
129263
129714
  return { codeActions: undefined, sourceDisplay: undefined };
129264
129715
  }
@@ -145099,7 +145550,7 @@ var ts;
145099
145550
  /** Note: output node may be mutated input node. */
145100
145551
  function getNonformattedText(node, sourceFile, newLineCharacter) {
145101
145552
  var writer = createWriter(newLineCharacter);
145102
- var newLine = newLineCharacter === "\n" ? 1 /* LineFeed */ : 0 /* CarriageReturnLineFeed */;
145553
+ var newLine = ts.getNewLineKind(newLineCharacter);
145103
145554
  ts.createPrinter({
145104
145555
  newLine: newLine,
145105
145556
  neverAsciiEscape: true,
@@ -145564,21 +146015,16 @@ var ts;
145564
146015
  (function (codefix) {
145565
146016
  var errorCodeToFixes = ts.createMultiMap();
145566
146017
  var fixIdToRegistration = new ts.Map();
145567
- function diagnosticToString(diag) {
145568
- return ts.isArray(diag)
145569
- ? ts.formatStringFromArgs(ts.getLocaleSpecificMessage(diag[0]), diag.slice(1))
145570
- : ts.getLocaleSpecificMessage(diag);
145571
- }
145572
146018
  function createCodeFixActionWithoutFixAll(fixName, changes, description) {
145573
- return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, /*fixId*/ undefined, /*fixAllDescription*/ undefined);
146019
+ return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, /*fixId*/ undefined, /*fixAllDescription*/ undefined);
145574
146020
  }
145575
146021
  codefix.createCodeFixActionWithoutFixAll = createCodeFixActionWithoutFixAll;
145576
146022
  function createCodeFixAction(fixName, changes, description, fixId, fixAllDescription, command) {
145577
- return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, diagnosticToString(fixAllDescription), command);
146023
+ return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, fixId, ts.diagnosticToString(fixAllDescription), command);
145578
146024
  }
145579
146025
  codefix.createCodeFixAction = createCodeFixAction;
145580
146026
  function createCodeFixActionMaybeFixAll(fixName, changes, description, fixId, fixAllDescription, command) {
145581
- return createCodeFixActionWorker(fixName, diagnosticToString(description), changes, fixId, fixAllDescription && diagnosticToString(fixAllDescription), command);
146027
+ return createCodeFixActionWorker(fixName, ts.diagnosticToString(description), changes, fixId, fixAllDescription && ts.diagnosticToString(fixAllDescription), command);
145582
146028
  }
145583
146029
  codefix.createCodeFixActionMaybeFixAll = createCodeFixActionMaybeFixAll;
145584
146030
  function createCodeFixActionWorker(fixName, description, changes, fixId, fixAllDescription, command) {
@@ -148339,7 +148785,7 @@ var ts;
148339
148785
  var addToExisting = new ts.Map();
148340
148786
  /** Use `getNewImportEntry` for access */
148341
148787
  var newImports = new ts.Map();
148342
- return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes };
148788
+ return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes, hasFixes: hasFixes };
148343
148789
  function addImportFromDiagnostic(diagnostic, context) {
148344
148790
  var info = getFixesInfo(context, diagnostic.code, diagnostic.start, useAutoImportProvider);
148345
148791
  if (!info || !info.fixes.length)
@@ -148490,6 +148936,9 @@ var ts;
148490
148936
  ts.insertImports(changeTracker, sourceFile, newDeclarations, /*blankLineBetween*/ true);
148491
148937
  }
148492
148938
  }
148939
+ function hasFixes() {
148940
+ return addToNamespace.length > 0 || importType.length > 0 || addToExisting.size > 0 || newImports.size > 0;
148941
+ }
148493
148942
  }
148494
148943
  // Sorted with the preferred fix coming first.
148495
148944
  var ImportFixKind;
@@ -152700,7 +153149,7 @@ var ts;
152700
153149
  for (var _i = 0, possiblyMissingSymbols_1 = possiblyMissingSymbols; _i < possiblyMissingSymbols_1.length; _i++) {
152701
153150
  var symbol = possiblyMissingSymbols_1[_i];
152702
153151
  if (!classMembers.has(symbol.escapedName)) {
152703
- addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement);
153152
+ addNewNodeForMemberSymbol(symbol, classDeclaration, sourceFile, context, preferences, importAdder, addClassElement, /* body */ undefined);
152704
153153
  }
152705
153154
  }
152706
153155
  }
@@ -152713,9 +153162,11 @@ var ts;
152713
153162
  }
152714
153163
  codefix.getNoopSymbolTrackerWithResolver = getNoopSymbolTrackerWithResolver;
152715
153164
  /**
152716
- * @returns Empty string iff there we can't figure out a representation for `symbol` in `enclosingDeclaration`.
153165
+ * `addClassElement` will not be called if we can't figure out a representation for `symbol` in `enclosingDeclaration`.
153166
+ * @param body If defined, this will be the body of the member node passed to `addClassElement`. Otherwise, the body will default to a stub.
152717
153167
  */
152718
- function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement) {
153168
+ function addNewNodeForMemberSymbol(symbol, enclosingDeclaration, sourceFile, context, preferences, importAdder, addClassElement, body, isAmbient) {
153169
+ if (isAmbient === void 0) { isAmbient = false; }
152719
153170
  var declarations = symbol.getDeclarations();
152720
153171
  if (!(declarations && declarations.length)) {
152721
153172
  return undefined;
@@ -152728,7 +153179,7 @@ var ts;
152728
153179
  var modifiers = visibilityModifier ? ts.factory.createNodeArray([visibilityModifier]) : undefined;
152729
153180
  var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
152730
153181
  var optional = !!(symbol.flags & 16777216 /* Optional */);
152731
- var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */);
153182
+ var ambient = !!(enclosingDeclaration.flags & 8388608 /* Ambient */) || isAmbient;
152732
153183
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
152733
153184
  switch (declaration.kind) {
152734
153185
  case 165 /* PropertySignature */:
@@ -152764,14 +153215,14 @@ var ts;
152764
153215
  var accessor = orderedAccessors_1[_i];
152765
153216
  if (ts.isGetAccessorDeclaration(accessor)) {
152766
153217
  addClassElement(ts.factory.createGetAccessorDeclaration(
152767
- /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : createStubbedMethodBody(quotePreference)));
153218
+ /*decorators*/ undefined, modifiers, name, ts.emptyArray, typeNode_1, ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
152768
153219
  }
152769
153220
  else {
152770
153221
  ts.Debug.assertNode(accessor, ts.isSetAccessorDeclaration, "The counterpart to a getter should be a setter");
152771
153222
  var parameter = ts.getSetAccessorValueParameter(accessor);
152772
153223
  var parameterName = parameter && ts.isIdentifier(parameter.name) ? ts.idText(parameter.name) : undefined;
152773
153224
  addClassElement(ts.factory.createSetAccessorDeclaration(
152774
- /*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : createStubbedMethodBody(quotePreference)));
153225
+ /*decorators*/ undefined, modifiers, name, createDummyParameters(1, [parameterName], [typeNode_1], 1, /*inJs*/ false), ambient ? undefined : body || createStubbedMethodBody(quotePreference)));
152775
153226
  }
152776
153227
  }
152777
153228
  break;
@@ -152792,7 +153243,7 @@ var ts;
152792
153243
  if (declarations.length === 1) {
152793
153244
  ts.Debug.assert(signatures.length === 1, "One declaration implies one signature");
152794
153245
  var signature = signatures[0];
152795
- outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : createStubbedMethodBody(quotePreference));
153246
+ outputMethod(quotePreference, signature, modifiers, name, ambient ? undefined : body || createStubbedMethodBody(quotePreference));
152796
153247
  break;
152797
153248
  }
152798
153249
  for (var _a = 0, signatures_1 = signatures; _a < signatures_1.length; _a++) {
@@ -152803,11 +153254,11 @@ var ts;
152803
153254
  if (!ambient) {
152804
153255
  if (declarations.length > signatures.length) {
152805
153256
  var signature = checker.getSignatureFromDeclaration(declarations[declarations.length - 1]);
152806
- outputMethod(quotePreference, signature, modifiers, name, createStubbedMethodBody(quotePreference));
153257
+ outputMethod(quotePreference, signature, modifiers, name, body || createStubbedMethodBody(quotePreference));
152807
153258
  }
152808
153259
  else {
152809
153260
  ts.Debug.assert(declarations.length === signatures.length, "Declarations and signatures should match count");
152810
- addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference));
153261
+ addClassElement(createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body));
152811
153262
  }
152812
153263
  }
152813
153264
  break;
@@ -152818,6 +153269,7 @@ var ts;
152818
153269
  addClassElement(method);
152819
153270
  }
152820
153271
  }
153272
+ codefix.addNewNodeForMemberSymbol = addNewNodeForMemberSymbol;
152821
153273
  function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
152822
153274
  var program = context.program;
152823
153275
  var checker = program.getTypeChecker();
@@ -152955,7 +153407,7 @@ var ts;
152955
153407
  }
152956
153408
  return parameters;
152957
153409
  }
152958
- function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference) {
153410
+ function createMethodImplementingSignatures(checker, context, enclosingDeclaration, signatures, name, optional, modifiers, quotePreference, body) {
152959
153411
  /** This is *a* signature with the maximal number of arguments,
152960
153412
  * such that if there is a "maximal" signature without rest arguments,
152961
153413
  * this is one of them.
@@ -152986,7 +153438,7 @@ var ts;
152986
153438
  parameters.push(restParameter);
152987
153439
  }
152988
153440
  return createStubbedMethod(modifiers, name, optional,
152989
- /*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference);
153441
+ /*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference, body);
152990
153442
  }
152991
153443
  function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) {
152992
153444
  if (ts.length(signatures)) {
@@ -152994,10 +153446,10 @@ var ts;
152994
153446
  return checker.typeToTypeNode(type, enclosingDeclaration, /*flags*/ undefined, getNoopSymbolTrackerWithResolver(context));
152995
153447
  }
152996
153448
  }
152997
- function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference) {
153449
+ function createStubbedMethod(modifiers, name, optional, typeParameters, parameters, returnType, quotePreference, body) {
152998
153450
  return ts.factory.createMethodDeclaration(
152999
153451
  /*decorators*/ undefined, modifiers,
153000
- /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, createStubbedMethodBody(quotePreference));
153452
+ /*asteriskToken*/ undefined, name, optional ? ts.factory.createToken(57 /* QuestionToken */) : undefined, typeParameters, parameters, returnType, body || createStubbedMethodBody(quotePreference));
153001
153453
  }
153002
153454
  function createStubbedMethodBody(quotePreference) {
153003
153455
  return createStubbedBody(ts.Diagnostics.Method_not_implemented.message, quotePreference);