@typescript-deploys/pr-build 4.7.0-pr-48168-8 → 4.7.0-pr-47657-5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/tsserver.js CHANGED
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-insiders.20220309";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220311";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -2099,13 +2099,15 @@ var ts;
2099
2099
  for (var _i = 0; _i < arguments.length; _i++) {
2100
2100
  args[_i] = arguments[_i];
2101
2101
  }
2102
+ var lastResult;
2102
2103
  for (var _a = 0, fs_1 = fs; _a < fs_1.length; _a++) {
2103
2104
  var f = fs_1[_a];
2104
- if (f.apply(void 0, args)) {
2105
- return true;
2105
+ lastResult = f.apply(void 0, args);
2106
+ if (lastResult) {
2107
+ return lastResult;
2106
2108
  }
2107
2109
  }
2108
- return false;
2110
+ return lastResult;
2109
2111
  };
2110
2112
  }
2111
2113
  ts.or = or;
@@ -5125,6 +5127,21 @@ var ts;
5125
5127
  ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12";
5126
5128
  ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext";
5127
5129
  })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
5130
+ var ModuleDetectionKind;
5131
+ (function (ModuleDetectionKind) {
5132
+ /**
5133
+ * Files with imports, exports and/or import.meta are considered modules
5134
+ */
5135
+ ModuleDetectionKind[ModuleDetectionKind["Legacy"] = 1] = "Legacy";
5136
+ /**
5137
+ * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+
5138
+ */
5139
+ ModuleDetectionKind[ModuleDetectionKind["Auto"] = 2] = "Auto";
5140
+ /**
5141
+ * Consider all non-declaration files modules, regardless of present syntax
5142
+ */
5143
+ ModuleDetectionKind[ModuleDetectionKind["Force"] = 3] = "Force";
5144
+ })(ModuleDetectionKind = ts.ModuleDetectionKind || (ts.ModuleDetectionKind = {}));
5128
5145
  var WatchFileKind;
5129
5146
  (function (WatchFileKind) {
5130
5147
  WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval";
@@ -8222,6 +8239,8 @@ var ts;
8222
8239
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
8223
8240
  An_import_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1473, ts.DiagnosticCategory.Error, "An_import_declaration_can_only_be_used_at_the_top_level_of_a_module_1473", "An import declaration can only be used at the top level of a module."),
8224
8241
  An_export_declaration_can_only_be_used_at_the_top_level_of_a_module: diag(1474, ts.DiagnosticCategory.Error, "An_export_declaration_can_only_be_used_at_the_top_level_of_a_module_1474", "An export declaration can only be used at the top level of a module."),
8242
+ Control_what_method_is_used_to_detect_module_format_JS_files: diag(1475, ts.DiagnosticCategory.Message, "Control_what_method_is_used_to_detect_module_format_JS_files_1475", "Control what method is used to detect module-format JS files."),
8243
+ auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules: diag(1476, ts.DiagnosticCategory.Message, "auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_w_1476", "\"auto\": Treat files with imports, exports, import.meta, jsx (with jsx: react-jsx), or esm format (with module: node12+) as modules."),
8225
8244
  The_types_of_0_are_incompatible_between_these_types: diag(2200, ts.DiagnosticCategory.Error, "The_types_of_0_are_incompatible_between_these_types_2200", "The types of '{0}' are incompatible between these types."),
8226
8245
  The_types_returned_by_0_are_incompatible_between_these_types: diag(2201, ts.DiagnosticCategory.Error, "The_types_returned_by_0_are_incompatible_between_these_types_2201", "The types returned by '{0}' are incompatible between these types."),
8227
8246
  Call_signature_return_types_0_and_1_are_incompatible: diag(2202, ts.DiagnosticCategory.Error, "Call_signature_return_types_0_and_1_are_incompatible_2202", "Call signature return types '{0}' and '{1}' are incompatible.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
@@ -19731,6 +19750,61 @@ var ts;
19731
19750
  return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */;
19732
19751
  }
19733
19752
  ts.getLanguageVariant = getLanguageVariant;
19753
+ /**
19754
+ * This is a somewhat unavoidable full tree walk to locate a JSX tag - `import.meta` requires the same,
19755
+ * but we avoid that walk (or parts of it) if at all possible using the `PossiblyContainsImportMeta` node flag.
19756
+ * Unfortunately, there's no `NodeFlag` space to do the same for JSX.
19757
+ */
19758
+ function walkTreeForJSXTags(node) {
19759
+ if (!(node.transformFlags & 2 /* ContainsJsx */))
19760
+ return undefined;
19761
+ return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags);
19762
+ }
19763
+ function isFileModuleFromUsingJSXTag(file) {
19764
+ // Excludes declaration files - they still require an explicit `export {}` or the like
19765
+ // for back compat purposes. (not that declaration files should contain JSX tags!)
19766
+ return !file.isDeclarationFile ? walkTreeForJSXTags(file) : undefined;
19767
+ }
19768
+ /**
19769
+ * Note that this requires file.impliedNodeFormat be set already; meaning it must be set very early on
19770
+ * in SourceFile construction.
19771
+ */
19772
+ function isFileForcedToBeModuleByFormat(file) {
19773
+ // Excludes declaration files - they still require an explicit `export {}` or the like
19774
+ // for back compat purposes.
19775
+ return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
19776
+ }
19777
+ function getSetExternalModuleIndicator(options) {
19778
+ // TODO: Should this callback be cached?
19779
+ switch (getEmitModuleDetectionKind(options)) {
19780
+ case ts.ModuleDetectionKind.Force:
19781
+ // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
19782
+ return function (file) {
19783
+ file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
19784
+ };
19785
+ case ts.ModuleDetectionKind.Legacy:
19786
+ // Files are modules if they have imports, exports, or import.meta
19787
+ return function (file) {
19788
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file);
19789
+ };
19790
+ case ts.ModuleDetectionKind.Auto:
19791
+ // If module is nodenext or node12, all esm format files are modules
19792
+ // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness
19793
+ // otherwise, the presence of import or export statments (or import.meta) implies module-ness
19794
+ var checks = [ts.isFileProbablyExternalModule];
19795
+ if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
19796
+ checks.push(isFileModuleFromUsingJSXTag);
19797
+ }
19798
+ var moduleKind = getEmitModuleKind(options);
19799
+ if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
19800
+ checks.push(isFileForcedToBeModuleByFormat);
19801
+ }
19802
+ var combined_1 = ts.or.apply(void 0, checks);
19803
+ var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
19804
+ return callback;
19805
+ }
19806
+ }
19807
+ ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator;
19734
19808
  function getEmitScriptTarget(compilerOptions) {
19735
19809
  return compilerOptions.target ||
19736
19810
  (compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) ||
@@ -19765,6 +19839,10 @@ var ts;
19765
19839
  return moduleResolution;
19766
19840
  }
19767
19841
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
19842
+ function getEmitModuleDetectionKind(options) {
19843
+ return options.moduleDetection || ts.ModuleDetectionKind.Auto;
19844
+ }
19845
+ ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
19768
19846
  function hasJsonModuleEmitEnabled(options) {
19769
19847
  switch (getEmitModuleKind(options)) {
19770
19848
  case ts.ModuleKind.CommonJS:
@@ -29935,6 +30013,36 @@ var ts;
29935
30013
  text.charCodeAt(start + 3) !== 47 /* slash */;
29936
30014
  }
29937
30015
  ts.isJSDocLikeText = isJSDocLikeText;
30016
+ /*@internal*/
30017
+ function isFileProbablyExternalModule(sourceFile) {
30018
+ // Try to use the first top-level import/export when available, then
30019
+ // fall back to looking for an 'import.meta' somewhere in the tree if necessary.
30020
+ return ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
30021
+ getImportMetaIfNecessary(sourceFile);
30022
+ }
30023
+ ts.isFileProbablyExternalModule = isFileProbablyExternalModule;
30024
+ function isAnExternalModuleIndicatorNode(node) {
30025
+ return hasModifierOfKind(node, 93 /* ExportKeyword */)
30026
+ || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
30027
+ || ts.isImportDeclaration(node)
30028
+ || ts.isExportAssignment(node)
30029
+ || ts.isExportDeclaration(node) ? node : undefined;
30030
+ }
30031
+ function getImportMetaIfNecessary(sourceFile) {
30032
+ return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ?
30033
+ walkTreeForImportMeta(sourceFile) :
30034
+ undefined;
30035
+ }
30036
+ function walkTreeForImportMeta(node) {
30037
+ return isImportMeta(node) ? node : forEachChild(node, walkTreeForImportMeta);
30038
+ }
30039
+ /** Do not use hasModifier inside the parser; it relies on parent pointers. Use this instead. */
30040
+ function hasModifierOfKind(node, kind) {
30041
+ return ts.some(node.modifiers, function (m) { return m.kind === kind; });
30042
+ }
30043
+ function isImportMeta(node) {
30044
+ return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta";
30045
+ }
29938
30046
  /**
29939
30047
  * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
29940
30048
  * stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
@@ -30516,17 +30624,25 @@ var ts;
30516
30624
  children.unshift(n);
30517
30625
  }
30518
30626
  }
30519
- function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
30627
+ function setExternalModuleIndicator(sourceFile) {
30628
+ sourceFile.externalModuleIndicator = isFileProbablyExternalModule(sourceFile);
30629
+ }
30630
+ function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) {
30520
30631
  if (setParentNodes === void 0) { setParentNodes = false; }
30521
30632
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
30522
30633
  ts.performance.mark("beforeParse");
30523
30634
  var result;
30524
30635
  ts.perfLogger.logStartParseSourceFile(fileName);
30636
+ var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat;
30525
30637
  if (languageVersion === 100 /* JSON */) {
30526
- result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */);
30638
+ result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop);
30527
30639
  }
30528
30640
  else {
30529
- result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind);
30641
+ var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) {
30642
+ file.impliedNodeFormat = format;
30643
+ return (overrideSetExternalModuleIndicator || setExternalModuleIndicator)(file);
30644
+ };
30645
+ result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind, setIndicator);
30530
30646
  }
30531
30647
  ts.perfLogger.logStopParseSourceFile();
30532
30648
  ts.performance.mark("afterParse");
@@ -30712,7 +30828,7 @@ var ts;
30712
30828
  // Note: any errors at the end of the file that do not precede a regular node, should get
30713
30829
  // attached to the EOF token.
30714
30830
  var parseErrorBeforeNextFinishedNode = false;
30715
- function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
30831
+ function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind, setExternalModuleIndicatorOverride) {
30716
30832
  var _a;
30717
30833
  if (setParentNodes === void 0) { setParentNodes = false; }
30718
30834
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
@@ -30728,7 +30844,7 @@ var ts;
30728
30844
  return result_3;
30729
30845
  }
30730
30846
  initializeState(fileName, sourceText, languageVersion, syntaxCursor, scriptKind);
30731
- var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind);
30847
+ var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicatorOverride || setExternalModuleIndicator);
30732
30848
  clearState();
30733
30849
  return result;
30734
30850
  }
@@ -30812,7 +30928,7 @@ var ts;
30812
30928
  endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token);
30813
30929
  }
30814
30930
  // Set source file so that errors will be reported with this file name
30815
- var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags);
30931
+ var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop);
30816
30932
  if (setParentNodes) {
30817
30933
  fixupParentReferences(sourceFile);
30818
30934
  }
@@ -30886,7 +31002,7 @@ var ts;
30886
31002
  notParenthesizedArrow = undefined;
30887
31003
  topLevel = true;
30888
31004
  }
30889
- function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
31005
+ function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
30890
31006
  var isDeclarationFile = isDeclarationFileName(fileName);
30891
31007
  if (isDeclarationFile) {
30892
31008
  contextFlags |= 8388608 /* Ambient */;
@@ -30897,7 +31013,7 @@ var ts;
30897
31013
  var statements = parseList(0 /* SourceElements */, parseStatement);
30898
31014
  ts.Debug.assert(token() === 1 /* EndOfFileToken */);
30899
31015
  var endOfFileToken = addJSDocComment(parseTokenNode());
30900
- var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags);
31016
+ var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator);
30901
31017
  // A member of ReadonlyArray<T> isn't assignable to a member of T[] (and prevents a direct cast) - but this is where we set up those members so they can be readonly in the future
30902
31018
  processCommentPragmas(sourceFile, sourceText);
30903
31019
  processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
@@ -31034,25 +31150,30 @@ var ts;
31034
31150
  ts.setParentRecursive(rootNode, /*incremental*/ true);
31035
31151
  }
31036
31152
  Parser.fixupParentReferences = fixupParentReferences;
31037
- function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags) {
31153
+ function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags, setExternalModuleIndicator) {
31038
31154
  // code from createNode is inlined here so createNode won't have to deal with special case of creating source files
31039
31155
  // this is quite rare comparing to other nodes and createNode should be as fast as possible
31040
31156
  var sourceFile = factory.createSourceFile(statements, endOfFileToken, flags);
31041
31157
  ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
31042
- setExternalModuleIndicator(sourceFile);
31158
+ setFields(sourceFile);
31043
31159
  // If we parsed this as an external module, it may contain top-level await
31044
31160
  if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) {
31045
31161
  sourceFile = reparseTopLevelAwait(sourceFile);
31162
+ setFields(sourceFile);
31046
31163
  }
31047
- sourceFile.text = sourceText;
31048
- sourceFile.bindDiagnostics = [];
31049
- sourceFile.bindSuggestionDiagnostics = undefined;
31050
- sourceFile.languageVersion = languageVersion;
31051
- sourceFile.fileName = fileName;
31052
- sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
31053
- sourceFile.isDeclarationFile = isDeclarationFile;
31054
- sourceFile.scriptKind = scriptKind;
31055
31164
  return sourceFile;
31165
+ function setFields(sourceFile) {
31166
+ sourceFile.text = sourceText;
31167
+ sourceFile.bindDiagnostics = [];
31168
+ sourceFile.bindSuggestionDiagnostics = undefined;
31169
+ sourceFile.languageVersion = languageVersion;
31170
+ sourceFile.fileName = fileName;
31171
+ sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
31172
+ sourceFile.isDeclarationFile = isDeclarationFile;
31173
+ sourceFile.scriptKind = scriptKind;
31174
+ setExternalModuleIndicator(sourceFile);
31175
+ sourceFile.setExternalModuleIndicator = setExternalModuleIndicator;
31176
+ }
31056
31177
  }
31057
31178
  function setContextFlag(val, flag) {
31058
31179
  if (val) {
@@ -36535,35 +36656,6 @@ var ts;
36535
36656
  var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression);
36536
36657
  return withJSDoc(finishNode(node, pos), hasJSDoc);
36537
36658
  }
36538
- function setExternalModuleIndicator(sourceFile) {
36539
- // Try to use the first top-level import/export when available, then
36540
- // fall back to looking for an 'import.meta' somewhere in the tree if necessary.
36541
- sourceFile.externalModuleIndicator =
36542
- ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
36543
- getImportMetaIfNecessary(sourceFile);
36544
- }
36545
- function isAnExternalModuleIndicatorNode(node) {
36546
- return hasModifierOfKind(node, 93 /* ExportKeyword */)
36547
- || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
36548
- || ts.isImportDeclaration(node)
36549
- || ts.isExportAssignment(node)
36550
- || ts.isExportDeclaration(node) ? node : undefined;
36551
- }
36552
- function getImportMetaIfNecessary(sourceFile) {
36553
- return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ?
36554
- walkTreeForExternalModuleIndicators(sourceFile) :
36555
- undefined;
36556
- }
36557
- function walkTreeForExternalModuleIndicators(node) {
36558
- return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators);
36559
- }
36560
- /** Do not use hasModifier inside the parser; it relies on parent pointers. Use this instead. */
36561
- function hasModifierOfKind(node, kind) {
36562
- return ts.some(node.modifiers, function (m) { return m.kind === kind; });
36563
- }
36564
- function isImportMeta(node) {
36565
- return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta";
36566
- }
36567
36659
  var ParsingContext;
36568
36660
  (function (ParsingContext) {
36569
36661
  ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements";
@@ -36606,7 +36698,7 @@ var ts;
36606
36698
  scanner.setText(content, start, length);
36607
36699
  currentToken = scanner.scan();
36608
36700
  var jsDocTypeExpression = parseJSDocTypeExpression();
36609
- var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */);
36701
+ var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop);
36610
36702
  var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
36611
36703
  if (jsDocDiagnostics) {
36612
36704
  sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
@@ -37567,7 +37659,7 @@ var ts;
37567
37659
  if (sourceFile.statements.length === 0) {
37568
37660
  // If we don't have any statements in the current source file, then there's no real
37569
37661
  // way to incrementally parse. So just do a full parse instead.
37570
- return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind);
37662
+ return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind, sourceFile.setExternalModuleIndicator);
37571
37663
  }
37572
37664
  // Make sure we're not trying to incrementally update a source file more than once. Once
37573
37665
  // we do an update the original source file is considered unusable from that point onwards.
@@ -37624,7 +37716,7 @@ var ts;
37624
37716
  // inconsistent tree. Setting the parents on the new tree should be very fast. We
37625
37717
  // will immediately bail out of walking any subtrees when we can see that their parents
37626
37718
  // are already correct.
37627
- var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind);
37719
+ var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind, sourceFile.setExternalModuleIndicator);
37628
37720
  result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
37629
37721
  result.impliedNodeFormat = sourceFile.impliedNodeFormat;
37630
37722
  return result;
@@ -39540,6 +39632,18 @@ var ts;
39540
39632
  description: ts.Diagnostics.Specify_a_list_of_language_service_plugins_to_include,
39541
39633
  category: ts.Diagnostics.Editor_Support,
39542
39634
  },
39635
+ {
39636
+ name: "moduleDetection",
39637
+ type: new ts.Map(ts.getEntries({
39638
+ auto: ts.ModuleDetectionKind.Auto,
39639
+ legacy: ts.ModuleDetectionKind.Legacy,
39640
+ force: ts.ModuleDetectionKind.Force,
39641
+ })),
39642
+ affectsModuleResolution: true,
39643
+ description: ts.Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files,
39644
+ category: ts.Diagnostics.Language_and_Environment,
39645
+ defaultValueDescription: ts.Diagnostics.auto_Colon_Treat_files_with_imports_exports_import_meta_jsx_with_jsx_Colon_react_jsx_or_esm_format_with_module_Colon_node12_as_modules,
39646
+ }
39543
39647
  ];
39544
39648
  /* @internal */
39545
39649
  ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild, true), commandOptionsWithoutBuild, true);
@@ -63493,7 +63597,8 @@ var ts;
63493
63597
  return true;
63494
63598
  }
63495
63599
  }
63496
- else {
63600
+ else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) {
63601
+ // We have excluded types that may simplify to other forms, so types must have identical flags
63497
63602
  if (source.flags !== target.flags)
63498
63603
  return false;
63499
63604
  if (source.flags & 67358815 /* Singleton */)
@@ -69569,7 +69674,7 @@ var ts;
69569
69674
  return result;
69570
69675
  }
69571
69676
  function getCandidateDiscriminantPropertyAccess(expr) {
69572
- if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference)) {
69677
+ if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference) || ts.isObjectLiteralMethod(reference)) {
69573
69678
  // When the reference is a binding pattern or function or arrow expression, we are narrowing a pesudo-reference in
69574
69679
  // getNarrowedTypeOfSymbol. An identifier for a destructuring variable declared in the same binding pattern or
69575
69680
  // parameter declared in the same parameter list is a candidate.
@@ -76541,6 +76646,9 @@ var ts;
76541
76646
  assignBindingElementTypes(declaration.name, links.type);
76542
76647
  }
76543
76648
  }
76649
+ else if (type) {
76650
+ ts.Debug.assertEqual(links.type, type, "Parameter symbol already has a cached type which differs from newly assigned type");
76651
+ }
76544
76652
  }
76545
76653
  // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
76546
76654
  // the destructured type into the contained binding elements.
@@ -114346,7 +114454,7 @@ var ts;
114346
114454
  var existingDirectories = new ts.Map();
114347
114455
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
114348
114456
  var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
114349
- function getSourceFile(fileName, languageVersion, onError) {
114457
+ function getSourceFile(fileName, languageVersionOrOptions, onError) {
114350
114458
  var text;
114351
114459
  try {
114352
114460
  ts.performance.mark("beforeIORead");
@@ -114360,7 +114468,7 @@ var ts;
114360
114468
  }
114361
114469
  text = "";
114362
114470
  }
114363
- return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
114471
+ return text !== undefined ? ts.createSourceFile(fileName, text, languageVersionOrOptions, setParentNodes) : undefined;
114364
114472
  }
114365
114473
  function directoryExists(directoryPath) {
114366
114474
  if (existingDirectories.has(directoryPath)) {
@@ -115766,8 +115874,8 @@ var ts;
115766
115874
  for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
115767
115875
  var oldSourceFile = oldSourceFiles_2[_i];
115768
115876
  var newSourceFile = host.getSourceFileByPath
115769
- ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile)
115770
- : host.getSourceFile(oldSourceFile.fileName, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
115877
+ ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile)
115878
+ : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
115771
115879
  if (!newSourceFile) {
115772
115880
  return 0 /* Not */;
115773
115881
  }
@@ -115798,7 +115906,6 @@ var ts;
115798
115906
  newSourceFile.originalFileName = oldSourceFile.originalFileName;
115799
115907
  newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
115800
115908
  newSourceFile.fileName = oldSourceFile.fileName;
115801
- newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
115802
115909
  var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
115803
115910
  if (packageName !== undefined) {
115804
115911
  // If there are 2 different source files for the same package name and at least one of them changes,
@@ -116717,6 +116824,17 @@ var ts;
116717
116824
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
116718
116825
  return result;
116719
116826
  }
116827
+ function getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options) {
116828
+ // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
116829
+ // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
116830
+ // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
116831
+ var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
116832
+ return {
116833
+ languageVersion: ts.getEmitScriptTarget(options),
116834
+ impliedNodeFormat: impliedNodeFormat,
116835
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options)
116836
+ };
116837
+ }
116720
116838
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
116721
116839
  var path = toPath(fileName);
116722
116840
  if (useSourceOfProjectReferenceRedirect) {
@@ -116804,7 +116922,7 @@ var ts;
116804
116922
  }
116805
116923
  }
116806
116924
  // We haven't looked for this file, do so now and cache result
116807
- var file = host.getSourceFile(fileName, ts.getEmitScriptTarget(options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile);
116925
+ var file = host.getSourceFile(fileName, getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options), function (hostErrorMessage) { return addFilePreprocessingFileExplainingDiagnostic(/*file*/ undefined, reason, ts.Diagnostics.Cannot_read_file_0_Colon_1, [fileName, hostErrorMessage]); }, shouldCreateNewSourceFile);
116808
116926
  if (packageId) {
116809
116927
  var packageIdKey = ts.packageIdToString(packageId);
116810
116928
  var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
@@ -116832,10 +116950,6 @@ var ts;
116832
116950
  file.path = path;
116833
116951
  file.resolvedPath = toPath(fileName);
116834
116952
  file.originalFileName = originalFileName;
116835
- // It's a _little odd_ that we can't set `impliedNodeFormat` until the program step - but it's the first and only time we have a resolution cache
116836
- // and a freshly made source file node on hand at the same time, and we need both to set the field. Persisting the resolution cache all the way
116837
- // to the check and emit steps would be bad - so we much prefer detecting and storing the format information on the source file node upfront.
116838
- file.impliedNodeFormat = getImpliedNodeFormatForFile(file.resolvedPath, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
116839
116953
  addFileIncludeReason(file, reason);
116840
116954
  if (host.useCaseSensitiveFileNames()) {
116841
116955
  var pathLowerCase = ts.toFileNameLowerCase(path);
@@ -117337,7 +117451,7 @@ var ts;
117337
117451
  }
117338
117452
  else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) {
117339
117453
  // We cannot use createDiagnosticFromNode because nodes do not have parents yet
117340
- var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117454
+ var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117341
117455
  programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
117342
117456
  }
117343
117457
  // Cannot specify module gen that isn't amd or system with --out
@@ -117346,7 +117460,7 @@ var ts;
117346
117460
  createDiagnosticForOptionName(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
117347
117461
  }
117348
117462
  else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
117349
- var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117463
+ var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117350
117464
  programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_compile_modules_using_option_0_unless_the_module_flag_is_amd_or_system, options.out ? "out" : "outFile"));
117351
117465
  }
117352
117466
  }
@@ -121608,7 +121722,7 @@ var ts;
121608
121722
  var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
121609
121723
  var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); });
121610
121724
  return {
121611
- getSourceFile: function (fileName, languageVersion, onError) {
121725
+ getSourceFile: function (fileName, languageVersionOrOptions, onError) {
121612
121726
  var text;
121613
121727
  try {
121614
121728
  ts.performance.mark("beforeIORead");
@@ -121622,7 +121736,7 @@ var ts;
121622
121736
  }
121623
121737
  text = "";
121624
121738
  }
121625
- return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined;
121739
+ return text !== undefined ? ts.createSourceFile(fileName, text, languageVersionOrOptions) : undefined;
121626
121740
  },
121627
121741
  getDefaultLibLocation: ts.maybeBind(host, host.getDefaultLibLocation),
121628
121742
  getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
@@ -122090,7 +122204,7 @@ var ts;
122090
122204
  }
122091
122205
  return directoryStructureHost.fileExists(fileName);
122092
122206
  }
122093
- function getVersionedSourceFileByPath(fileName, path, languageVersion, onError, shouldCreateNewSourceFile) {
122207
+ function getVersionedSourceFileByPath(fileName, path, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
122094
122208
  var hostSourceFile = sourceFilesCache.get(path);
122095
122209
  // No source file on the host
122096
122210
  if (isFileMissingOnHost(hostSourceFile)) {
@@ -122098,7 +122212,7 @@ var ts;
122098
122212
  }
122099
122213
  // Create new source file if requested or the versions dont match
122100
122214
  if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
122101
- var sourceFile = getNewSourceFile(fileName, languageVersion, onError);
122215
+ var sourceFile = getNewSourceFile(fileName, languageVersionOrOptions, onError);
122102
122216
  if (hostSourceFile) {
122103
122217
  if (sourceFile) {
122104
122218
  // Set the source file and create file watcher now that file was present on the disk
@@ -126716,14 +126830,6 @@ var ts;
126716
126830
  });
126717
126831
  }
126718
126832
  ts.signatureToDisplayParts = signatureToDisplayParts;
126719
- function nodeToDisplayParts(node, enclosingDeclaration) {
126720
- var file = enclosingDeclaration.getSourceFile();
126721
- return mapToDisplayParts(function (writer) {
126722
- var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
126723
- printer.writeNode(4 /* Unspecified */, node, file, writer);
126724
- });
126725
- }
126726
- ts.nodeToDisplayParts = nodeToDisplayParts;
126727
126833
  function isImportOrExportSpecifierName(location) {
126728
126834
  return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
126729
126835
  }
@@ -130064,8 +130170,6 @@ var ts;
130064
130170
  CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
130065
130171
  /** A type-only import that needs to be promoted in order to be used at the completion location */
130066
130172
  CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
130067
- /** Auto-import that comes attached to an object literal method snippet */
130068
- CompletionSource["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
130069
130173
  })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
130070
130174
  var SymbolOriginInfoKind;
130071
130175
  (function (SymbolOriginInfoKind) {
@@ -130076,7 +130180,6 @@ var ts;
130076
130180
  SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
130077
130181
  SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
130078
130182
  SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
130079
- SymbolOriginInfoKind[SymbolOriginInfoKind["ObjectLiteralMethod"] = 128] = "ObjectLiteralMethod";
130080
130183
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
130081
130184
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
130082
130185
  })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
@@ -130107,9 +130210,6 @@ var ts;
130107
130210
  function originIsTypeOnlyAlias(origin) {
130108
130211
  return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
130109
130212
  }
130110
- function originIsObjectLiteralMethod(origin) {
130111
- return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */);
130112
- }
130113
130213
  var KeywordCompletionFilters;
130114
130214
  (function (KeywordCompletionFilters) {
130115
130215
  KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
@@ -130535,20 +130635,6 @@ var ts;
130535
130635
  source = CompletionSource.ClassMemberSnippet;
130536
130636
  }
130537
130637
  }
130538
- if (origin && originIsObjectLiteralMethod(origin)) {
130539
- var objectLiteral = ts.cast(tryGetObjectLikeCompletionContainer(contextToken), ts.isObjectLiteralExpression);
130540
- var importAdder = void 0;
130541
- var entry = getEntryForObjectLiteralMethodCompletion(symbol, name, objectLiteral, program, host, options, preferences, formatContext);
130542
- if (!entry) {
130543
- return undefined;
130544
- }
130545
- (insertText = entry.insertText, isSnippet = entry.isSnippet, importAdder = entry.importAdder, sourceDisplay = entry.sourceDisplay);
130546
- source = CompletionSource.ObjectLiteralMethodSnippet;
130547
- sortText = SortText.OptionalMember;
130548
- if (importAdder.hasFixes()) {
130549
- hasAction = true;
130550
- }
130551
- }
130552
130638
  if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
130553
130639
  var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
130554
130640
  var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
@@ -130707,15 +130793,27 @@ var ts;
130707
130793
  completionNodes.push(node);
130708
130794
  }, body, 2 /* Property */, isAbstract);
130709
130795
  if (completionNodes.length) {
130710
- var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */;
130711
130796
  replacementSpan = modifiersSpan;
130712
130797
  // If we have access to formatting settings, we print the nodes using the emitter,
130713
130798
  // and then format the printed text.
130714
130799
  if (formatContext) {
130715
- insertText = printer.printAndFormatSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile, formatContext);
130800
+ var syntheticFile_1 = {
130801
+ text: printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile),
130802
+ getLineAndCharacterOfPosition: function (pos) {
130803
+ return ts.getLineAndCharacterOfPosition(this, pos);
130804
+ },
130805
+ };
130806
+ var formatOptions_1 = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
130807
+ var changes = ts.flatMap(completionNodes, function (node) {
130808
+ var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
130809
+ return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile_1, sourceFile.languageVariant,
130810
+ /* indentation */ 0,
130811
+ /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions_1 }));
130812
+ });
130813
+ insertText = ts.textChanges.applyChanges(syntheticFile_1.text, changes);
130716
130814
  }
130717
130815
  else { // Otherwise, just use emitter to print the new nodes.
130718
- insertText = printer.printSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile);
130816
+ insertText = printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
130719
130817
  }
130720
130818
  }
130721
130819
  return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder, replacementSpan: replacementSpan };
@@ -130765,92 +130863,12 @@ var ts;
130765
130863
  }
130766
130864
  return undefined;
130767
130865
  }
130768
- function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, options, preferences, formatContext) {
130769
- var isSnippet;
130770
- var insertText = name;
130771
- var sourceFile = enclosingDeclaration.getSourceFile();
130772
- var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
130773
- var body;
130774
- if (preferences.includeCompletionsWithSnippetText) {
130775
- isSnippet = true;
130776
- var emptyStmt = ts.factory.createEmptyStatement();
130777
- body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
130778
- ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 });
130779
- }
130780
- else {
130781
- body = ts.factory.createBlock([], /* multiline */ true);
130782
- }
130783
- var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder, /*body*/ body);
130784
- if (!method) {
130785
- return undefined;
130786
- }
130787
- var printer = createSnippetPrinter({
130788
- removeComments: true,
130789
- module: options.module,
130790
- target: options.target,
130791
- omitTrailingSemicolon: false,
130792
- newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
130793
- });
130794
- if (formatContext) {
130795
- insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext);
130796
- }
130797
- else {
130798
- insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile);
130799
- }
130800
- var methodSignature = ts.factory.createMethodSignature(method.modifiers, method.name, method.questionToken, method.typeParameters, method.parameters, method.type);
130801
- var sourceDisplay = ts.nodeToDisplayParts(methodSignature, enclosingDeclaration);
130802
- return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, sourceDisplay: sourceDisplay };
130803
- }
130804
- ;
130805
- function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder, body) {
130806
- var declarations = symbol.getDeclarations();
130807
- if (!(declarations && declarations.length)) {
130808
- return undefined;
130809
- }
130810
- var checker = program.getTypeChecker();
130811
- var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
130812
- var declaration = declarations[0];
130813
- var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
130814
- var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
130815
- var quotePreference = ts.getQuotePreference(sourceFile, preferences);
130816
- var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
130817
- switch (declaration.kind) {
130818
- case 165 /* PropertySignature */:
130819
- case 166 /* PropertyDeclaration */:
130820
- case 167 /* MethodSignature */:
130821
- case 168 /* MethodDeclaration */: {
130822
- var signatures = checker.getSignaturesOfType(type, 0 /* Call */);
130823
- if (signatures.length > 1) {
130824
- // We don't support overloads in object literals.
130825
- return undefined;
130826
- }
130827
- var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, builderFlags, ts.codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host }));
130828
- var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
130829
- if (importableReference) {
130830
- typeNode = importableReference.typeNode;
130831
- ts.codefix.importSymbols(importAdder, importableReference.symbols);
130832
- }
130833
- if (!typeNode) {
130834
- return undefined;
130835
- }
130836
- ts.Debug.assertNode(typeNode, ts.isFunctionTypeNode);
130837
- return ts.factory.createMethodDeclaration(
130838
- /*decorators*/ undefined,
130839
- /*modifiers*/ undefined,
130840
- /*asteriskToken*/ undefined, name,
130841
- /*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body);
130842
- }
130843
- default:
130844
- return undefined;
130845
- }
130846
- }
130847
130866
  function createSnippetPrinter(printerOptions) {
130848
130867
  var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
130849
130868
  var printer = ts.createPrinter(printerOptions, baseWriter);
130850
130869
  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)); } });
130851
130870
  return {
130852
130871
  printSnippetList: printSnippetList,
130853
- printAndFormatSnippetList: printAndFormatSnippetList,
130854
130872
  };
130855
130873
  /* Snippet-escaping version of `printer.printList`. */
130856
130874
  function printSnippetList(format, list, sourceFile) {
@@ -130858,22 +130876,6 @@ var ts;
130858
130876
  printer.writeList(format, list, sourceFile, writer);
130859
130877
  return writer.getText();
130860
130878
  }
130861
- function printAndFormatSnippetList(format, list, sourceFile, formatContext) {
130862
- var syntheticFile = {
130863
- text: printSnippetList(format, list, sourceFile),
130864
- getLineAndCharacterOfPosition: function (pos) {
130865
- return ts.getLineAndCharacterOfPosition(this, pos);
130866
- },
130867
- };
130868
- var formatOptions = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
130869
- var changes = ts.flatMap(list, function (node) {
130870
- var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
130871
- return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile, sourceFile.languageVariant,
130872
- /* indentation */ 0,
130873
- /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions }));
130874
- });
130875
- return ts.textChanges.applyChanges(syntheticFile.text, changes);
130876
- }
130877
130879
  }
130878
130880
  function originToCompletionEntryData(origin) {
130879
130881
  var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
@@ -130986,7 +130988,7 @@ var ts;
130986
130988
  var symbol = symbols[i];
130987
130989
  var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
130988
130990
  var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected);
130989
- if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextIdMap && !shouldIncludeSymbol(symbol, symbolToSortTextIdMap)) {
130991
+ if (!info || uniques.get(info.name) || kind === 1 /* Global */ && symbolToSortTextIdMap && !shouldIncludeSymbol(symbol, symbolToSortTextIdMap)) {
130990
130992
  continue;
130991
130993
  }
130992
130994
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
@@ -131117,9 +131119,7 @@ var ts;
131117
131119
  return ts.firstDefined(symbols, function (symbol, index) {
131118
131120
  var origin = symbolToOriginInfoMap[index];
131119
131121
  var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
131120
- return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */
131121
- || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */)
131122
- || getSourceFromOrigin(origin) === entryId.source)
131122
+ return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ || getSourceFromOrigin(origin) === entryId.source)
131123
131123
  ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
131124
131124
  : undefined;
131125
131125
  }) || { type: "none" };
@@ -131201,20 +131201,6 @@ var ts;
131201
131201
  };
131202
131202
  }
131203
131203
  }
131204
- if (source === CompletionSource.ObjectLiteralMethodSnippet) {
131205
- var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
131206
- var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
131207
- if (importAdder.hasFixes()) {
131208
- var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
131209
- return {
131210
- sourceDisplay: undefined,
131211
- codeActions: [{
131212
- changes: changes,
131213
- description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
131214
- }],
131215
- };
131216
- }
131217
- }
131218
131204
  if (originIsTypeOnlyAlias(origin)) {
131219
131205
  var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
131220
131206
  ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
@@ -132101,45 +132087,6 @@ var ts;
132101
132087
  symbolToSortTextIdMap[symbolId] = importCompletionNode ? 11 /* LocationPriority */ : 16 /* AutoImportSuggestions */;
132102
132088
  symbols.push(symbol);
132103
132089
  }
132104
- /* Mutates `symbols` and `symbolToOriginInfoMap`. */
132105
- function collectObjectLiteralMethodSymbols(members) {
132106
- // TODO: support JS files.
132107
- if (ts.isInJSFile(location)) {
132108
- return;
132109
- }
132110
- members = members.slice(); // Needed in case `symbol` and `members` are the same array.
132111
- for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
132112
- var member = members_1[_i];
132113
- if (!isObjectLiteralMethodSymbol(member)) {
132114
- continue;
132115
- }
132116
- var origin = { kind: 128 /* ObjectLiteralMethod */ };
132117
- symbolToOriginInfoMap[symbols.length] = origin;
132118
- symbols.push(member);
132119
- }
132120
- }
132121
- function isObjectLiteralMethodSymbol(symbol) {
132122
- /*
132123
- For an object type
132124
- `type Foo = {
132125
- bar(x: number): void;
132126
- foo: (x: string) => string;
132127
- }`,
132128
- `bar` will have symbol flag `Method`,
132129
- `foo` will have symbol flag `Property`.
132130
- */
132131
- if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) {
132132
- return false;
132133
- }
132134
- if (symbol.flags & 4 /* Property */) {
132135
- var type = program.getTypeChecker().getTypeOfSymbol(symbol);
132136
- // We ignore non-function properties.
132137
- if (!type.getCallSignatures().length) {
132138
- return false;
132139
- }
132140
- }
132141
- return true;
132142
- }
132143
132090
  /**
132144
132091
  * Finds the first node that "embraces" the position, so that one may
132145
132092
  * accurately aggregate locals from the closest containing scope.
@@ -132337,11 +132284,7 @@ var ts;
132337
132284
  }
132338
132285
  if (typeMembers && typeMembers.length > 0) {
132339
132286
  // Add filtered items to the completion list
132340
- var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers));
132341
- symbols = ts.concatenate(symbols, filteredMembers);
132342
- if (objectLikeContainer.kind === 204 /* ObjectLiteralExpression */ && preferences.includeCompletionsWithInsertText) {
132343
- collectObjectLiteralMethodSymbols(filteredMembers);
132344
- }
132287
+ symbols = ts.concatenate(symbols, filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers)));
132345
132288
  }
132346
132289
  setSortTextToOptionalMember();
132347
132290
  return 1 /* Success */;
@@ -132473,6 +132416,29 @@ var ts;
132473
132416
  }
132474
132417
  return 1 /* Success */;
132475
132418
  }
132419
+ /**
132420
+ * Returns the immediate owning object literal or binding pattern of a context token,
132421
+ * on the condition that one exists and that the context implies completion should be given.
132422
+ */
132423
+ function tryGetObjectLikeCompletionContainer(contextToken) {
132424
+ if (contextToken) {
132425
+ var parent = contextToken.parent;
132426
+ switch (contextToken.kind) {
132427
+ case 18 /* OpenBraceToken */: // const x = { |
132428
+ case 27 /* CommaToken */: // const x = { a: 0, |
132429
+ if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
132430
+ return parent;
132431
+ }
132432
+ break;
132433
+ case 41 /* AsteriskToken */:
132434
+ return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
132435
+ case 79 /* Identifier */:
132436
+ return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
132437
+ ? contextToken.parent.parent : undefined;
132438
+ }
132439
+ }
132440
+ return undefined;
132441
+ }
132476
132442
  function isConstructorParameterCompletion(node) {
132477
132443
  return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent)
132478
132444
  && (ts.isParameterPropertyModifier(node.kind) || ts.isDeclarationName(node));
@@ -132895,29 +132861,6 @@ var ts;
132895
132861
  return node.getStart(sourceFile) <= position && position <= node.getEnd();
132896
132862
  }
132897
132863
  }
132898
- /**
132899
- * Returns the immediate owning object literal or binding pattern of a context token,
132900
- * on the condition that one exists and that the context implies completion should be given.
132901
- */
132902
- function tryGetObjectLikeCompletionContainer(contextToken) {
132903
- if (contextToken) {
132904
- var parent = contextToken.parent;
132905
- switch (contextToken.kind) {
132906
- case 18 /* OpenBraceToken */: // const x = { |
132907
- case 27 /* CommaToken */: // const x = { a: 0, |
132908
- if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
132909
- return parent;
132910
- }
132911
- break;
132912
- case 41 /* AsteriskToken */:
132913
- return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
132914
- case 79 /* Identifier */:
132915
- return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
132916
- ? contextToken.parent.parent : undefined;
132917
- }
132918
- }
132919
- return undefined;
132920
- }
132921
132864
  function getRelevantTokens(position, sourceFile) {
132922
132865
  var previousToken = ts.findPrecedingToken(position, sourceFile);
132923
132866
  if (previousToken && position <= previousToken.end && (ts.isMemberName(previousToken) || ts.isKeyword(previousToken.kind))) {
@@ -133957,9 +133900,15 @@ var ts;
133957
133900
  });
133958
133901
  return JSON.stringify(bucketInfoArray, undefined, 2);
133959
133902
  }
133903
+ function getCompilationSettings(settingsOrHost) {
133904
+ if (typeof settingsOrHost.getCompilationSettings === "function") {
133905
+ return settingsOrHost.getCompilationSettings();
133906
+ }
133907
+ return settingsOrHost;
133908
+ }
133960
133909
  function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
133961
133910
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
133962
- var key = getKeyForCompilationSettings(compilationSettings);
133911
+ var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
133963
133912
  return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
133964
133913
  }
133965
133914
  function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
@@ -133967,20 +133916,28 @@ var ts;
133967
133916
  }
133968
133917
  function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
133969
133918
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
133970
- var key = getKeyForCompilationSettings(compilationSettings);
133919
+ var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
133971
133920
  return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
133972
133921
  }
133973
133922
  function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
133974
- return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
133923
+ return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
133975
133924
  }
133976
133925
  function getDocumentRegistryEntry(bucketEntry, scriptKind) {
133977
133926
  var entry = isDocumentRegistryEntry(bucketEntry) ? bucketEntry : bucketEntry.get(ts.Debug.checkDefined(scriptKind, "If there are more than one scriptKind's for same document the scriptKind should be provided"));
133978
133927
  ts.Debug.assert(scriptKind === undefined || !entry || entry.sourceFile.scriptKind === scriptKind, "Script kind should match provided ScriptKind:" + scriptKind + " and sourceFile.scriptKind: " + (entry === null || entry === void 0 ? void 0 : entry.sourceFile.scriptKind) + ", !entry: " + !entry);
133979
133928
  return entry;
133980
133929
  }
133981
- function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) {
133930
+ function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) {
133931
+ var _a, _b, _c, _d;
133982
133932
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
133933
+ var compilationSettings = getCompilationSettings(compilationSettingsOrHost);
133934
+ var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost;
133983
133935
  var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
133936
+ var sourceFileOptions = {
133937
+ languageVersion: scriptTarget,
133938
+ impliedNodeFormat: host && ts.getImpliedNodeFormatForFile(path, (_d = (_c = (_b = (_a = host.getCompilerHost) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getModuleResolutionCache) === null || _c === void 0 ? void 0 : _c.call(_b)) === null || _d === void 0 ? void 0 : _d.getPackageJsonInfoCache(), host, compilationSettings),
133939
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings)
133940
+ };
133984
133941
  var oldBucketCount = buckets.size;
133985
133942
  var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
133986
133943
  if (ts.tracing) {
@@ -134014,7 +133971,7 @@ var ts;
134014
133971
  }
134015
133972
  if (!entry) {
134016
133973
  // Have never seen this file with these settings. Create a new source file for it.
134017
- var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, /*setNodeParents*/ false, scriptKind);
133974
+ var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind);
134018
133975
  if (externalCache) {
134019
133976
  externalCache.setDocument(key, path, sourceFile);
134020
133977
  }
@@ -140948,6 +140905,41 @@ var ts;
140948
140905
  if (ts.scanner.getToken() === 1 /* EndOfFileToken */) {
140949
140906
  break;
140950
140907
  }
140908
+ if (ts.scanner.getToken() === 15 /* TemplateHead */) {
140909
+ var stack = [ts.scanner.getToken()];
140910
+ var token = ts.scanner.scan();
140911
+ loop: while (ts.length(stack)) {
140912
+ switch (token) {
140913
+ case 1 /* EndOfFileToken */:
140914
+ break loop;
140915
+ case 100 /* ImportKeyword */:
140916
+ tryConsumeImport();
140917
+ break;
140918
+ case 15 /* TemplateHead */:
140919
+ stack.push(token);
140920
+ break;
140921
+ case 18 /* OpenBraceToken */:
140922
+ if (ts.length(stack)) {
140923
+ stack.push(token);
140924
+ }
140925
+ break;
140926
+ case 19 /* CloseBraceToken */:
140927
+ if (ts.length(stack)) {
140928
+ if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) {
140929
+ if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) {
140930
+ stack.pop();
140931
+ }
140932
+ }
140933
+ else {
140934
+ stack.pop();
140935
+ }
140936
+ }
140937
+ break;
140938
+ }
140939
+ token = ts.scanner.scan();
140940
+ }
140941
+ nextToken();
140942
+ }
140951
140943
  // check if at least one of alternative have moved scanner forward
140952
140944
  if (tryConsumeDeclare() ||
140953
140945
  tryConsumeImport() ||
@@ -142458,7 +142450,7 @@ var ts;
142458
142450
  continue;
142459
142451
  var module_1 = ts.getResolvedModule(sourceFile, moduleSpecifier.text, ts.getModeForUsageLocation(sourceFile, moduleSpecifier));
142460
142452
  var resolvedFile = module_1 && program.getSourceFile(module_1.resolvedFileName);
142461
- if (resolvedFile && resolvedFile.externalModuleIndicator && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
142453
+ if (resolvedFile && resolvedFile.externalModuleIndicator && resolvedFile.externalModuleIndicator !== true && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
142462
142454
  diags.push(ts.createDiagnosticForNode(name, ts.Diagnostics.Import_may_be_converted_to_a_default_import));
142463
142455
  }
142464
142456
  }
@@ -143374,19 +143366,7 @@ var ts;
143374
143366
  options.suppressOutputPathCheck = true;
143375
143367
  // Filename can be non-ts file.
143376
143368
  options.allowNonTsExtensions = true;
143377
- // if jsx is specified then treat file as .tsx
143378
- var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts");
143379
- var sourceFile = ts.createSourceFile(inputFileName, input, ts.getEmitScriptTarget(options));
143380
- if (transpileOptions.moduleName) {
143381
- sourceFile.moduleName = transpileOptions.moduleName;
143382
- }
143383
- if (transpileOptions.renamedDependencies) {
143384
- sourceFile.renamedDependencies = new ts.Map(ts.getEntries(transpileOptions.renamedDependencies));
143385
- }
143386
143369
  var newLine = ts.getNewLineCharacter(options);
143387
- // Output
143388
- var outputText;
143389
- var sourceMapText;
143390
143370
  // Create a compilerHost object to allow the compiler to read and write files
143391
143371
  var compilerHost = {
143392
143372
  getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; },
@@ -143410,6 +143390,22 @@ var ts;
143410
143390
  directoryExists: function () { return true; },
143411
143391
  getDirectories: function () { return []; }
143412
143392
  };
143393
+ // if jsx is specified then treat file as .tsx
143394
+ var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts");
143395
+ var sourceFile = ts.createSourceFile(inputFileName, input, {
143396
+ languageVersion: ts.getEmitScriptTarget(options),
143397
+ impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(inputFileName, "", compilerHost.getCanonicalFileName), /*cache*/ undefined, compilerHost, options),
143398
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options)
143399
+ });
143400
+ if (transpileOptions.moduleName) {
143401
+ sourceFile.moduleName = transpileOptions.moduleName;
143402
+ }
143403
+ if (transpileOptions.renamedDependencies) {
143404
+ sourceFile.renamedDependencies = new ts.Map(ts.getEntries(transpileOptions.renamedDependencies));
143405
+ }
143406
+ // Output
143407
+ var outputText;
143408
+ var sourceMapText;
143413
143409
  var program = ts.createProgram([inputFileName], options, compilerHost);
143414
143410
  if (transpileOptions.reportDiagnostics) {
143415
143411
  ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile));
@@ -155315,7 +155311,6 @@ var ts;
155315
155311
  if (!ts.some(signatures)) {
155316
155312
  break;
155317
155313
  }
155318
- // >> TODO: call `try get auto importable reference from type node` on type nodes?
155319
155314
  if (declarations.length === 1) {
155320
155315
  ts.Debug.assert(signatures.length === 1, "One declaration implies one signature");
155321
155316
  var signature = signatures[0];
@@ -155346,27 +155341,6 @@ var ts;
155346
155341
  }
155347
155342
  }
155348
155343
  codefix.addNewNodeForMemberSymbol = addNewNodeForMemberSymbol;
155349
- // export function addNewNodeObjectLiteralProperties(
155350
- // // changes: textChanges.ChangeTracker,
155351
- // // context: CodeFixContextBase,
155352
- // sourceFile: SourceFile,
155353
- // program: Program,
155354
- // preferences: UserPreferences,
155355
- // host: LanguageServiceHost,
155356
- // // info: ObjectLiteralInfo,
155357
- // properties: Symbol[],
155358
- // addNodes: (nodes: PropertyAssignment[]) => void,
155359
- // ): void {
155360
- // const importAdder = createImportAdder(sourceFile, program, preferences, host);
155361
- // const quotePreference = getQuotePreference(sourceFile, preferences);
155362
- // const target = getEmitScriptTarget(program.getCompilerOptions());
155363
- // const checker = program.getTypeChecker();
155364
- // const props = map(properties, prop => {
155365
- // const initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop));
155366
- // return factory.createPropertyAssignment(createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === QuotePreference.Single), initializer);
155367
- // });
155368
- // addNodes(props);
155369
- // }
155370
155344
  function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
155371
155345
  var program = context.program;
155372
155346
  var checker = program.getTypeChecker();
@@ -155536,7 +155510,6 @@ var ts;
155536
155510
  return createStubbedMethod(modifiers, name, optional,
155537
155511
  /*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference, body);
155538
155512
  }
155539
- codefix.createMethodImplementingSignatures = createMethodImplementingSignatures;
155540
155513
  function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) {
155541
155514
  if (ts.length(signatures)) {
155542
155515
  var type = checker.getUnionType(ts.map(signatures, checker.getReturnTypeOfSignature));
@@ -158764,8 +158737,8 @@ var ts;
158764
158737
  ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one.
158765
158738
  var prevMember;
158766
158739
  var allProperties = true;
158767
- for (var _i = 0, members_2 = members; _i < members_2.length; _i++) {
158768
- var member = members_2[_i];
158740
+ for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
158741
+ var member = members_1[_i];
158769
158742
  if (member.pos > maxPos) {
158770
158743
  return prevMember || members[0];
158771
158744
  }
@@ -159945,7 +159918,7 @@ var ts;
159945
159918
  for (var i = 1;; i++) {
159946
159919
  var name = ts.combinePaths(inDirectory, newModuleName + extension);
159947
159920
  if (!host.fileExists(name))
159948
- return newModuleName; // TODO: GH#18217
159921
+ return newModuleName;
159949
159922
  newModuleName = moduleName + "." + i;
159950
159923
  }
159951
159924
  }
@@ -162305,6 +162278,7 @@ var ts;
162305
162278
  this.host = host;
162306
162279
  }
162307
162280
  SyntaxTreeCache.prototype.getCurrentSourceFile = function (fileName) {
162281
+ var _a, _b, _c, _d, _e, _f, _g, _h;
162308
162282
  var scriptSnapshot = this.host.getScriptSnapshot(fileName);
162309
162283
  if (!scriptSnapshot) {
162310
162284
  // The host does not know about this file.
@@ -162315,7 +162289,12 @@ var ts;
162315
162289
  var sourceFile;
162316
162290
  if (this.currentFileName !== fileName) {
162317
162291
  // This is a new file, just parse it
162318
- sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 99 /* Latest */, version, /*setNodeParents*/ true, scriptKind);
162292
+ var options = {
162293
+ languageVersion: 99 /* Latest */,
162294
+ impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(fileName, this.host.getCurrentDirectory(), ((_c = (_b = (_a = this.host).getCompilerHost) === null || _b === void 0 ? void 0 : _b.call(_a)) === null || _c === void 0 ? void 0 : _c.getCanonicalFileName) || ts.hostGetCanonicalFileName(this.host)), (_h = (_g = (_f = (_e = (_d = this.host).getCompilerHost) === null || _e === void 0 ? void 0 : _e.call(_d)) === null || _f === void 0 ? void 0 : _f.getModuleResolutionCache) === null || _g === void 0 ? void 0 : _g.call(_f)) === null || _h === void 0 ? void 0 : _h.getPackageJsonInfoCache(), this.host, this.host.getCompilationSettings()),
162295
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.host.getCompilationSettings())
162296
+ };
162297
+ sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, options, version, /*setNodeParents*/ true, scriptKind);
162319
162298
  }
162320
162299
  else if (this.currentFileVersion !== version) {
162321
162300
  // This is the same file, just a newer version. Incrementally parse the file.
@@ -162337,8 +162316,8 @@ var ts;
162337
162316
  sourceFile.version = version;
162338
162317
  sourceFile.scriptSnapshot = scriptSnapshot;
162339
162318
  }
162340
- function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents, scriptKind) {
162341
- var sourceFile = ts.createSourceFile(fileName, ts.getSnapshotText(scriptSnapshot), scriptTarget, setNodeParents, scriptKind);
162319
+ function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTargetOrOptions, version, setNodeParents, scriptKind) {
162320
+ var sourceFile = ts.createSourceFile(fileName, ts.getSnapshotText(scriptSnapshot), scriptTargetOrOptions, setNodeParents, scriptKind);
162342
162321
  setSourceFileFields(sourceFile, scriptSnapshot, version);
162343
162322
  return sourceFile;
162344
162323
  }
@@ -162386,8 +162365,13 @@ var ts;
162386
162365
  return newSourceFile;
162387
162366
  }
162388
162367
  }
162368
+ var options = {
162369
+ languageVersion: sourceFile.languageVersion,
162370
+ impliedNodeFormat: sourceFile.impliedNodeFormat,
162371
+ setExternalModuleIndicator: sourceFile.setExternalModuleIndicator,
162372
+ };
162389
162373
  // Otherwise, just create a new source file.
162390
- return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true, sourceFile.scriptKind);
162374
+ return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, options, version, /*setNodeParents*/ true, sourceFile.scriptKind);
162391
162375
  }
162392
162376
  ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile;
162393
162377
  var NoopCancellationToken = {
@@ -162731,7 +162715,7 @@ var ts;
162731
162715
  // file's script kind, i.e. in one project some file is treated as ".ts"
162732
162716
  // and in another as ".js"
162733
162717
  if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) {
162734
- return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
162718
+ return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
162735
162719
  }
162736
162720
  else {
162737
162721
  // Release old source file and fall through to aquire new file with new script kind
@@ -162741,7 +162725,7 @@ var ts;
162741
162725
  // We didn't already have the file. Fall through and acquire it from the registry.
162742
162726
  }
162743
162727
  // Could not find this file in the old program, create a new SourceFile for it.
162744
- return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
162728
+ return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
162745
162729
  }
162746
162730
  }
162747
162731
  // TODO: GH#18217 frequently asserted as defined
@@ -168288,6 +168272,10 @@ var ts;
168288
168272
  this.packageJsonsForAutoImport = new ts.Set(packageJsons.map(function (p) { return p.fileName; }));
168289
168273
  return packageJsons;
168290
168274
  };
168275
+ /* @internal */
168276
+ Project.prototype.getPackageJsonCache = function () {
168277
+ return this.projectService.packageJsonCache;
168278
+ };
168291
168279
  /*@internal*/
168292
168280
  Project.prototype.getCachedExportInfoMap = function () {
168293
168281
  return this.exportMapCache || (this.exportMapCache = ts.createCacheableExportInfoMap(this));