@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.
@@ -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-insiders.20220309";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220311";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -2293,13 +2293,15 @@ var ts;
2293
2293
  for (var _i = 0; _i < arguments.length; _i++) {
2294
2294
  args[_i] = arguments[_i];
2295
2295
  }
2296
+ var lastResult;
2296
2297
  for (var _a = 0, fs_1 = fs; _a < fs_1.length; _a++) {
2297
2298
  var f = fs_1[_a];
2298
- if (f.apply(void 0, args)) {
2299
- return true;
2299
+ lastResult = f.apply(void 0, args);
2300
+ if (lastResult) {
2301
+ return lastResult;
2300
2302
  }
2301
2303
  }
2302
- return false;
2304
+ return lastResult;
2303
2305
  };
2304
2306
  }
2305
2307
  ts.or = or;
@@ -5319,6 +5321,21 @@ var ts;
5319
5321
  ModuleResolutionKind[ModuleResolutionKind["Node12"] = 3] = "Node12";
5320
5322
  ModuleResolutionKind[ModuleResolutionKind["NodeNext"] = 99] = "NodeNext";
5321
5323
  })(ModuleResolutionKind = ts.ModuleResolutionKind || (ts.ModuleResolutionKind = {}));
5324
+ var ModuleDetectionKind;
5325
+ (function (ModuleDetectionKind) {
5326
+ /**
5327
+ * Files with imports, exports and/or import.meta are considered modules
5328
+ */
5329
+ ModuleDetectionKind[ModuleDetectionKind["Legacy"] = 1] = "Legacy";
5330
+ /**
5331
+ * Legacy, but also files with jsx under react-jsx or react-jsxdev and esm mode files under moduleResolution: node12+
5332
+ */
5333
+ ModuleDetectionKind[ModuleDetectionKind["Auto"] = 2] = "Auto";
5334
+ /**
5335
+ * Consider all non-declaration files modules, regardless of present syntax
5336
+ */
5337
+ ModuleDetectionKind[ModuleDetectionKind["Force"] = 3] = "Force";
5338
+ })(ModuleDetectionKind = ts.ModuleDetectionKind || (ts.ModuleDetectionKind = {}));
5322
5339
  var WatchFileKind;
5323
5340
  (function (WatchFileKind) {
5324
5341
  WatchFileKind[WatchFileKind["FixedPollingInterval"] = 0] = "FixedPollingInterval";
@@ -8416,6 +8433,8 @@ var ts;
8416
8433
  catch_or_finally_expected: diag(1472, ts.DiagnosticCategory.Error, "catch_or_finally_expected_1472", "'catch' or 'finally' expected."),
8417
8434
  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."),
8418
8435
  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."),
8436
+ 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."),
8437
+ 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."),
8419
8438
  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."),
8420
8439
  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."),
8421
8440
  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),
@@ -19925,6 +19944,61 @@ var ts;
19925
19944
  return scriptKind === 4 /* TSX */ || scriptKind === 2 /* JSX */ || scriptKind === 1 /* JS */ || scriptKind === 6 /* JSON */ ? 1 /* JSX */ : 0 /* Standard */;
19926
19945
  }
19927
19946
  ts.getLanguageVariant = getLanguageVariant;
19947
+ /**
19948
+ * This is a somewhat unavoidable full tree walk to locate a JSX tag - `import.meta` requires the same,
19949
+ * but we avoid that walk (or parts of it) if at all possible using the `PossiblyContainsImportMeta` node flag.
19950
+ * Unfortunately, there's no `NodeFlag` space to do the same for JSX.
19951
+ */
19952
+ function walkTreeForJSXTags(node) {
19953
+ if (!(node.transformFlags & 2 /* ContainsJsx */))
19954
+ return undefined;
19955
+ return ts.isJsxOpeningLikeElement(node) || ts.isJsxFragment(node) ? node : ts.forEachChild(node, walkTreeForJSXTags);
19956
+ }
19957
+ function isFileModuleFromUsingJSXTag(file) {
19958
+ // Excludes declaration files - they still require an explicit `export {}` or the like
19959
+ // for back compat purposes. (not that declaration files should contain JSX tags!)
19960
+ return !file.isDeclarationFile ? walkTreeForJSXTags(file) : undefined;
19961
+ }
19962
+ /**
19963
+ * Note that this requires file.impliedNodeFormat be set already; meaning it must be set very early on
19964
+ * in SourceFile construction.
19965
+ */
19966
+ function isFileForcedToBeModuleByFormat(file) {
19967
+ // Excludes declaration files - they still require an explicit `export {}` or the like
19968
+ // for back compat purposes.
19969
+ return file.impliedNodeFormat === ts.ModuleKind.ESNext && !file.isDeclarationFile ? true : undefined;
19970
+ }
19971
+ function getSetExternalModuleIndicator(options) {
19972
+ // TODO: Should this callback be cached?
19973
+ switch (getEmitModuleDetectionKind(options)) {
19974
+ case ts.ModuleDetectionKind.Force:
19975
+ // All non-declaration files are modules, declaration files still do the usual isFileProbablyExternalModule
19976
+ return function (file) {
19977
+ file.externalModuleIndicator = !file.isDeclarationFile || ts.isFileProbablyExternalModule(file);
19978
+ };
19979
+ case ts.ModuleDetectionKind.Legacy:
19980
+ // Files are modules if they have imports, exports, or import.meta
19981
+ return function (file) {
19982
+ file.externalModuleIndicator = ts.isFileProbablyExternalModule(file);
19983
+ };
19984
+ case ts.ModuleDetectionKind.Auto:
19985
+ // If module is nodenext or node12, all esm format files are modules
19986
+ // If jsx is react-jsx or react-jsxdev then jsx tags force module-ness
19987
+ // otherwise, the presence of import or export statments (or import.meta) implies module-ness
19988
+ var checks = [ts.isFileProbablyExternalModule];
19989
+ if (options.jsx === 4 /* ReactJSX */ || options.jsx === 5 /* ReactJSXDev */) {
19990
+ checks.push(isFileModuleFromUsingJSXTag);
19991
+ }
19992
+ var moduleKind = getEmitModuleKind(options);
19993
+ if (moduleKind === ts.ModuleKind.Node12 || moduleKind === ts.ModuleKind.NodeNext) {
19994
+ checks.push(isFileForcedToBeModuleByFormat);
19995
+ }
19996
+ var combined_1 = ts.or.apply(void 0, checks);
19997
+ var callback = function (file) { return void (file.externalModuleIndicator = combined_1(file)); };
19998
+ return callback;
19999
+ }
20000
+ }
20001
+ ts.getSetExternalModuleIndicator = getSetExternalModuleIndicator;
19928
20002
  function getEmitScriptTarget(compilerOptions) {
19929
20003
  return compilerOptions.target ||
19930
20004
  (compilerOptions.module === ts.ModuleKind.Node12 && 7 /* ES2020 */) ||
@@ -19959,6 +20033,10 @@ var ts;
19959
20033
  return moduleResolution;
19960
20034
  }
19961
20035
  ts.getEmitModuleResolutionKind = getEmitModuleResolutionKind;
20036
+ function getEmitModuleDetectionKind(options) {
20037
+ return options.moduleDetection || ts.ModuleDetectionKind.Auto;
20038
+ }
20039
+ ts.getEmitModuleDetectionKind = getEmitModuleDetectionKind;
19962
20040
  function hasJsonModuleEmitEnabled(options) {
19963
20041
  switch (getEmitModuleKind(options)) {
19964
20042
  case ts.ModuleKind.CommonJS:
@@ -30129,6 +30207,36 @@ var ts;
30129
30207
  text.charCodeAt(start + 3) !== 47 /* slash */;
30130
30208
  }
30131
30209
  ts.isJSDocLikeText = isJSDocLikeText;
30210
+ /*@internal*/
30211
+ function isFileProbablyExternalModule(sourceFile) {
30212
+ // Try to use the first top-level import/export when available, then
30213
+ // fall back to looking for an 'import.meta' somewhere in the tree if necessary.
30214
+ return ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
30215
+ getImportMetaIfNecessary(sourceFile);
30216
+ }
30217
+ ts.isFileProbablyExternalModule = isFileProbablyExternalModule;
30218
+ function isAnExternalModuleIndicatorNode(node) {
30219
+ return hasModifierOfKind(node, 93 /* ExportKeyword */)
30220
+ || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
30221
+ || ts.isImportDeclaration(node)
30222
+ || ts.isExportAssignment(node)
30223
+ || ts.isExportDeclaration(node) ? node : undefined;
30224
+ }
30225
+ function getImportMetaIfNecessary(sourceFile) {
30226
+ return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ?
30227
+ walkTreeForImportMeta(sourceFile) :
30228
+ undefined;
30229
+ }
30230
+ function walkTreeForImportMeta(node) {
30231
+ return isImportMeta(node) ? node : forEachChild(node, walkTreeForImportMeta);
30232
+ }
30233
+ /** Do not use hasModifier inside the parser; it relies on parent pointers. Use this instead. */
30234
+ function hasModifierOfKind(node, kind) {
30235
+ return ts.some(node.modifiers, function (m) { return m.kind === kind; });
30236
+ }
30237
+ function isImportMeta(node) {
30238
+ return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta";
30239
+ }
30132
30240
  /**
30133
30241
  * Invokes a callback for each child of the given node. The 'cbNode' callback is invoked for all child nodes
30134
30242
  * stored in properties. If a 'cbNodes' callback is specified, it is invoked for embedded arrays; otherwise,
@@ -30710,17 +30818,25 @@ var ts;
30710
30818
  children.unshift(n);
30711
30819
  }
30712
30820
  }
30713
- function createSourceFile(fileName, sourceText, languageVersion, setParentNodes, scriptKind) {
30821
+ function setExternalModuleIndicator(sourceFile) {
30822
+ sourceFile.externalModuleIndicator = isFileProbablyExternalModule(sourceFile);
30823
+ }
30824
+ function createSourceFile(fileName, sourceText, languageVersionOrOptions, setParentNodes, scriptKind) {
30714
30825
  if (setParentNodes === void 0) { setParentNodes = false; }
30715
30826
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("parse" /* Parse */, "createSourceFile", { path: fileName }, /*separateBeginAndEnd*/ true);
30716
30827
  ts.performance.mark("beforeParse");
30717
30828
  var result;
30718
30829
  ts.perfLogger.logStartParseSourceFile(fileName);
30830
+ var _a = typeof languageVersionOrOptions === "object" ? languageVersionOrOptions : { languageVersion: languageVersionOrOptions }, languageVersion = _a.languageVersion, overrideSetExternalModuleIndicator = _a.setExternalModuleIndicator, format = _a.impliedNodeFormat;
30719
30831
  if (languageVersion === 100 /* JSON */) {
30720
- result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */);
30832
+ result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, 6 /* JSON */, ts.noop);
30721
30833
  }
30722
30834
  else {
30723
- result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind);
30835
+ var setIndicator = format === undefined ? overrideSetExternalModuleIndicator : function (file) {
30836
+ file.impliedNodeFormat = format;
30837
+ return (overrideSetExternalModuleIndicator || setExternalModuleIndicator)(file);
30838
+ };
30839
+ result = Parser.parseSourceFile(fileName, sourceText, languageVersion, /*syntaxCursor*/ undefined, setParentNodes, scriptKind, setIndicator);
30724
30840
  }
30725
30841
  ts.perfLogger.logStopParseSourceFile();
30726
30842
  ts.performance.mark("afterParse");
@@ -30906,7 +31022,7 @@ var ts;
30906
31022
  // Note: any errors at the end of the file that do not precede a regular node, should get
30907
31023
  // attached to the EOF token.
30908
31024
  var parseErrorBeforeNextFinishedNode = false;
30909
- function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind) {
31025
+ function parseSourceFile(fileName, sourceText, languageVersion, syntaxCursor, setParentNodes, scriptKind, setExternalModuleIndicatorOverride) {
30910
31026
  var _a;
30911
31027
  if (setParentNodes === void 0) { setParentNodes = false; }
30912
31028
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
@@ -30922,7 +31038,7 @@ var ts;
30922
31038
  return result_3;
30923
31039
  }
30924
31040
  initializeState(fileName, sourceText, languageVersion, syntaxCursor, scriptKind);
30925
- var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind);
31041
+ var result = parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicatorOverride || setExternalModuleIndicator);
30926
31042
  clearState();
30927
31043
  return result;
30928
31044
  }
@@ -31006,7 +31122,7 @@ var ts;
31006
31122
  endOfFileToken = parseExpectedToken(1 /* EndOfFileToken */, ts.Diagnostics.Unexpected_token);
31007
31123
  }
31008
31124
  // Set source file so that errors will be reported with this file name
31009
- var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags);
31125
+ var sourceFile = createSourceFile(fileName, 2 /* ES2015 */, 6 /* JSON */, /*isDeclaration*/ false, statements, endOfFileToken, sourceFlags, ts.noop);
31010
31126
  if (setParentNodes) {
31011
31127
  fixupParentReferences(sourceFile);
31012
31128
  }
@@ -31080,7 +31196,7 @@ var ts;
31080
31196
  notParenthesizedArrow = undefined;
31081
31197
  topLevel = true;
31082
31198
  }
31083
- function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind) {
31199
+ function parseSourceFileWorker(languageVersion, setParentNodes, scriptKind, setExternalModuleIndicator) {
31084
31200
  var isDeclarationFile = isDeclarationFileName(fileName);
31085
31201
  if (isDeclarationFile) {
31086
31202
  contextFlags |= 8388608 /* Ambient */;
@@ -31091,7 +31207,7 @@ var ts;
31091
31207
  var statements = parseList(0 /* SourceElements */, parseStatement);
31092
31208
  ts.Debug.assert(token() === 1 /* EndOfFileToken */);
31093
31209
  var endOfFileToken = addJSDocComment(parseTokenNode());
31094
- var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags);
31210
+ var sourceFile = createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, sourceFlags, setExternalModuleIndicator);
31095
31211
  // 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
31096
31212
  processCommentPragmas(sourceFile, sourceText);
31097
31213
  processPragmasIntoFields(sourceFile, reportPragmaDiagnostic);
@@ -31228,25 +31344,30 @@ var ts;
31228
31344
  ts.setParentRecursive(rootNode, /*incremental*/ true);
31229
31345
  }
31230
31346
  Parser.fixupParentReferences = fixupParentReferences;
31231
- function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags) {
31347
+ function createSourceFile(fileName, languageVersion, scriptKind, isDeclarationFile, statements, endOfFileToken, flags, setExternalModuleIndicator) {
31232
31348
  // code from createNode is inlined here so createNode won't have to deal with special case of creating source files
31233
31349
  // this is quite rare comparing to other nodes and createNode should be as fast as possible
31234
31350
  var sourceFile = factory.createSourceFile(statements, endOfFileToken, flags);
31235
31351
  ts.setTextRangePosWidth(sourceFile, 0, sourceText.length);
31236
- setExternalModuleIndicator(sourceFile);
31352
+ setFields(sourceFile);
31237
31353
  // If we parsed this as an external module, it may contain top-level await
31238
31354
  if (!isDeclarationFile && isExternalModule(sourceFile) && sourceFile.transformFlags & 16777216 /* ContainsPossibleTopLevelAwait */) {
31239
31355
  sourceFile = reparseTopLevelAwait(sourceFile);
31356
+ setFields(sourceFile);
31240
31357
  }
31241
- sourceFile.text = sourceText;
31242
- sourceFile.bindDiagnostics = [];
31243
- sourceFile.bindSuggestionDiagnostics = undefined;
31244
- sourceFile.languageVersion = languageVersion;
31245
- sourceFile.fileName = fileName;
31246
- sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
31247
- sourceFile.isDeclarationFile = isDeclarationFile;
31248
- sourceFile.scriptKind = scriptKind;
31249
31358
  return sourceFile;
31359
+ function setFields(sourceFile) {
31360
+ sourceFile.text = sourceText;
31361
+ sourceFile.bindDiagnostics = [];
31362
+ sourceFile.bindSuggestionDiagnostics = undefined;
31363
+ sourceFile.languageVersion = languageVersion;
31364
+ sourceFile.fileName = fileName;
31365
+ sourceFile.languageVariant = ts.getLanguageVariant(scriptKind);
31366
+ sourceFile.isDeclarationFile = isDeclarationFile;
31367
+ sourceFile.scriptKind = scriptKind;
31368
+ setExternalModuleIndicator(sourceFile);
31369
+ sourceFile.setExternalModuleIndicator = setExternalModuleIndicator;
31370
+ }
31250
31371
  }
31251
31372
  function setContextFlag(val, flag) {
31252
31373
  if (val) {
@@ -36729,35 +36850,6 @@ var ts;
36729
36850
  var node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression);
36730
36851
  return withJSDoc(finishNode(node, pos), hasJSDoc);
36731
36852
  }
36732
- function setExternalModuleIndicator(sourceFile) {
36733
- // Try to use the first top-level import/export when available, then
36734
- // fall back to looking for an 'import.meta' somewhere in the tree if necessary.
36735
- sourceFile.externalModuleIndicator =
36736
- ts.forEach(sourceFile.statements, isAnExternalModuleIndicatorNode) ||
36737
- getImportMetaIfNecessary(sourceFile);
36738
- }
36739
- function isAnExternalModuleIndicatorNode(node) {
36740
- return hasModifierOfKind(node, 93 /* ExportKeyword */)
36741
- || ts.isImportEqualsDeclaration(node) && ts.isExternalModuleReference(node.moduleReference)
36742
- || ts.isImportDeclaration(node)
36743
- || ts.isExportAssignment(node)
36744
- || ts.isExportDeclaration(node) ? node : undefined;
36745
- }
36746
- function getImportMetaIfNecessary(sourceFile) {
36747
- return sourceFile.flags & 2097152 /* PossiblyContainsImportMeta */ ?
36748
- walkTreeForExternalModuleIndicators(sourceFile) :
36749
- undefined;
36750
- }
36751
- function walkTreeForExternalModuleIndicators(node) {
36752
- return isImportMeta(node) ? node : forEachChild(node, walkTreeForExternalModuleIndicators);
36753
- }
36754
- /** Do not use hasModifier inside the parser; it relies on parent pointers. Use this instead. */
36755
- function hasModifierOfKind(node, kind) {
36756
- return ts.some(node.modifiers, function (m) { return m.kind === kind; });
36757
- }
36758
- function isImportMeta(node) {
36759
- return ts.isMetaProperty(node) && node.keywordToken === 100 /* ImportKeyword */ && node.name.escapedText === "meta";
36760
- }
36761
36853
  var ParsingContext;
36762
36854
  (function (ParsingContext) {
36763
36855
  ParsingContext[ParsingContext["SourceElements"] = 0] = "SourceElements";
@@ -36800,7 +36892,7 @@ var ts;
36800
36892
  scanner.setText(content, start, length);
36801
36893
  currentToken = scanner.scan();
36802
36894
  var jsDocTypeExpression = parseJSDocTypeExpression();
36803
- var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */);
36895
+ var sourceFile = createSourceFile("file.js", 99 /* Latest */, 1 /* JS */, /*isDeclarationFile*/ false, [], factory.createToken(1 /* EndOfFileToken */), 0 /* None */, ts.noop);
36804
36896
  var diagnostics = ts.attachFileToDiagnostics(parseDiagnostics, sourceFile);
36805
36897
  if (jsDocDiagnostics) {
36806
36898
  sourceFile.jsDocDiagnostics = ts.attachFileToDiagnostics(jsDocDiagnostics, sourceFile);
@@ -37761,7 +37853,7 @@ var ts;
37761
37853
  if (sourceFile.statements.length === 0) {
37762
37854
  // If we don't have any statements in the current source file, then there's no real
37763
37855
  // way to incrementally parse. So just do a full parse instead.
37764
- return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind);
37856
+ return Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, /*syntaxCursor*/ undefined, /*setParentNodes*/ true, sourceFile.scriptKind, sourceFile.setExternalModuleIndicator);
37765
37857
  }
37766
37858
  // Make sure we're not trying to incrementally update a source file more than once. Once
37767
37859
  // we do an update the original source file is considered unusable from that point onwards.
@@ -37818,7 +37910,7 @@ var ts;
37818
37910
  // inconsistent tree. Setting the parents on the new tree should be very fast. We
37819
37911
  // will immediately bail out of walking any subtrees when we can see that their parents
37820
37912
  // are already correct.
37821
- var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind);
37913
+ var result = Parser.parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /*setParentNodes*/ true, sourceFile.scriptKind, sourceFile.setExternalModuleIndicator);
37822
37914
  result.commentDirectives = getNewCommentDirectives(sourceFile.commentDirectives, result.commentDirectives, changeRange.span.start, ts.textSpanEnd(changeRange.span), delta, oldText, newText, aggressiveChecks);
37823
37915
  result.impliedNodeFormat = sourceFile.impliedNodeFormat;
37824
37916
  return result;
@@ -39734,6 +39826,18 @@ var ts;
39734
39826
  description: ts.Diagnostics.Specify_a_list_of_language_service_plugins_to_include,
39735
39827
  category: ts.Diagnostics.Editor_Support,
39736
39828
  },
39829
+ {
39830
+ name: "moduleDetection",
39831
+ type: new ts.Map(ts.getEntries({
39832
+ auto: ts.ModuleDetectionKind.Auto,
39833
+ legacy: ts.ModuleDetectionKind.Legacy,
39834
+ force: ts.ModuleDetectionKind.Force,
39835
+ })),
39836
+ affectsModuleResolution: true,
39837
+ description: ts.Diagnostics.Control_what_method_is_used_to_detect_module_format_JS_files,
39838
+ category: ts.Diagnostics.Language_and_Environment,
39839
+ 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,
39840
+ }
39737
39841
  ];
39738
39842
  /* @internal */
39739
39843
  ts.optionDeclarations = __spreadArray(__spreadArray([], ts.commonOptionsWithBuild, true), commandOptionsWithoutBuild, true);
@@ -63687,7 +63791,8 @@ var ts;
63687
63791
  return true;
63688
63792
  }
63689
63793
  }
63690
- else {
63794
+ else if (!((source.flags | target.flags) & (3145728 /* UnionOrIntersection */ | 8388608 /* IndexedAccess */ | 16777216 /* Conditional */ | 33554432 /* Substitution */))) {
63795
+ // We have excluded types that may simplify to other forms, so types must have identical flags
63691
63796
  if (source.flags !== target.flags)
63692
63797
  return false;
63693
63798
  if (source.flags & 67358815 /* Singleton */)
@@ -69763,7 +69868,7 @@ var ts;
69763
69868
  return result;
69764
69869
  }
69765
69870
  function getCandidateDiscriminantPropertyAccess(expr) {
69766
- if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference)) {
69871
+ if (ts.isBindingPattern(reference) || ts.isFunctionExpressionOrArrowFunction(reference) || ts.isObjectLiteralMethod(reference)) {
69767
69872
  // When the reference is a binding pattern or function or arrow expression, we are narrowing a pesudo-reference in
69768
69873
  // getNarrowedTypeOfSymbol. An identifier for a destructuring variable declared in the same binding pattern or
69769
69874
  // parameter declared in the same parameter list is a candidate.
@@ -76735,6 +76840,9 @@ var ts;
76735
76840
  assignBindingElementTypes(declaration.name, links.type);
76736
76841
  }
76737
76842
  }
76843
+ else if (type) {
76844
+ ts.Debug.assertEqual(links.type, type, "Parameter symbol already has a cached type which differs from newly assigned type");
76845
+ }
76738
76846
  }
76739
76847
  // When contextual typing assigns a type to a parameter that contains a binding pattern, we also need to push
76740
76848
  // the destructured type into the contained binding elements.
@@ -114540,7 +114648,7 @@ var ts;
114540
114648
  var existingDirectories = new ts.Map();
114541
114649
  var getCanonicalFileName = ts.createGetCanonicalFileName(system.useCaseSensitiveFileNames);
114542
114650
  var computeHash = ts.maybeBind(system, system.createHash) || ts.generateDjb2Hash;
114543
- function getSourceFile(fileName, languageVersion, onError) {
114651
+ function getSourceFile(fileName, languageVersionOrOptions, onError) {
114544
114652
  var text;
114545
114653
  try {
114546
114654
  ts.performance.mark("beforeIORead");
@@ -114554,7 +114662,7 @@ var ts;
114554
114662
  }
114555
114663
  text = "";
114556
114664
  }
114557
- return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion, setParentNodes) : undefined;
114665
+ return text !== undefined ? ts.createSourceFile(fileName, text, languageVersionOrOptions, setParentNodes) : undefined;
114558
114666
  }
114559
114667
  function directoryExists(directoryPath) {
114560
114668
  if (existingDirectories.has(directoryPath)) {
@@ -115960,8 +116068,8 @@ var ts;
115960
116068
  for (var _i = 0, oldSourceFiles_2 = oldSourceFiles; _i < oldSourceFiles_2.length; _i++) {
115961
116069
  var oldSourceFile = oldSourceFiles_2[_i];
115962
116070
  var newSourceFile = host.getSourceFileByPath
115963
- ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile)
115964
- : host.getSourceFile(oldSourceFile.fileName, ts.getEmitScriptTarget(options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
116071
+ ? host.getSourceFileByPath(oldSourceFile.fileName, oldSourceFile.resolvedPath, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile)
116072
+ : host.getSourceFile(oldSourceFile.fileName, getCreateSourceFileOptions(oldSourceFile.fileName, moduleResolutionCache, host, options), /*onError*/ undefined, shouldCreateNewSourceFile); // TODO: GH#18217
115965
116073
  if (!newSourceFile) {
115966
116074
  return 0 /* Not */;
115967
116075
  }
@@ -115992,7 +116100,6 @@ var ts;
115992
116100
  newSourceFile.originalFileName = oldSourceFile.originalFileName;
115993
116101
  newSourceFile.resolvedPath = oldSourceFile.resolvedPath;
115994
116102
  newSourceFile.fileName = oldSourceFile.fileName;
115995
- newSourceFile.impliedNodeFormat = oldSourceFile.impliedNodeFormat;
115996
116103
  var packageName = oldProgram.sourceFileToPackageName.get(oldSourceFile.path);
115997
116104
  if (packageName !== undefined) {
115998
116105
  // If there are 2 different source files for the same package name and at least one of them changes,
@@ -116911,6 +117018,17 @@ var ts;
116911
117018
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
116912
117019
  return result;
116913
117020
  }
117021
+ function getCreateSourceFileOptions(fileName, moduleResolutionCache, host, options) {
117022
+ // 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
117023
+ // 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
117024
+ // 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.
117025
+ var impliedNodeFormat = getImpliedNodeFormatForFile(toPath(fileName), moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
117026
+ return {
117027
+ languageVersion: ts.getEmitScriptTarget(options),
117028
+ impliedNodeFormat: impliedNodeFormat,
117029
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options)
117030
+ };
117031
+ }
116914
117032
  function findSourceFileWorker(fileName, isDefaultLib, ignoreNoDefaultLib, reason, packageId) {
116915
117033
  var path = toPath(fileName);
116916
117034
  if (useSourceOfProjectReferenceRedirect) {
@@ -116998,7 +117116,7 @@ var ts;
116998
117116
  }
116999
117117
  }
117000
117118
  // We haven't looked for this file, do so now and cache result
117001
- 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);
117119
+ 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);
117002
117120
  if (packageId) {
117003
117121
  var packageIdKey = ts.packageIdToString(packageId);
117004
117122
  var fileFromPackageId = packageIdToSourceFile.get(packageIdKey);
@@ -117026,10 +117144,6 @@ var ts;
117026
117144
  file.path = path;
117027
117145
  file.resolvedPath = toPath(fileName);
117028
117146
  file.originalFileName = originalFileName;
117029
- // 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
117030
- // 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
117031
- // 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.
117032
- file.impliedNodeFormat = getImpliedNodeFormatForFile(file.resolvedPath, moduleResolutionCache === null || moduleResolutionCache === void 0 ? void 0 : moduleResolutionCache.getPackageJsonInfoCache(), host, options);
117033
117147
  addFileIncludeReason(file, reason);
117034
117148
  if (host.useCaseSensitiveFileNames()) {
117035
117149
  var pathLowerCase = ts.toFileNameLowerCase(path);
@@ -117531,7 +117645,7 @@ var ts;
117531
117645
  }
117532
117646
  else if (firstNonAmbientExternalModuleSourceFile && languageVersion < 2 /* ES2015 */ && options.module === ts.ModuleKind.None) {
117533
117647
  // We cannot use createDiagnosticFromNode because nodes do not have parents yet
117534
- var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117648
+ var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117535
117649
  programDiagnostics.add(ts.createFileDiagnostic(firstNonAmbientExternalModuleSourceFile, span.start, span.length, ts.Diagnostics.Cannot_use_imports_exports_or_module_augmentations_when_module_is_none));
117536
117650
  }
117537
117651
  // Cannot specify module gen that isn't amd or system with --out
@@ -117540,7 +117654,7 @@ var ts;
117540
117654
  createDiagnosticForOptionName(ts.Diagnostics.Only_amd_and_system_modules_are_supported_alongside_0, options.out ? "out" : "outFile", "module");
117541
117655
  }
117542
117656
  else if (options.module === undefined && firstNonAmbientExternalModuleSourceFile) {
117543
- var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117657
+ var span = ts.getErrorSpanForNode(firstNonAmbientExternalModuleSourceFile, typeof firstNonAmbientExternalModuleSourceFile.externalModuleIndicator === "boolean" ? firstNonAmbientExternalModuleSourceFile : firstNonAmbientExternalModuleSourceFile.externalModuleIndicator);
117544
117658
  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"));
117545
117659
  }
117546
117660
  }
@@ -121802,7 +121916,7 @@ var ts;
121802
121916
  var useCaseSensitiveFileNames = host.useCaseSensitiveFileNames();
121803
121917
  var hostGetNewLine = ts.memoize(function () { return host.getNewLine(); });
121804
121918
  return {
121805
- getSourceFile: function (fileName, languageVersion, onError) {
121919
+ getSourceFile: function (fileName, languageVersionOrOptions, onError) {
121806
121920
  var text;
121807
121921
  try {
121808
121922
  ts.performance.mark("beforeIORead");
@@ -121816,7 +121930,7 @@ var ts;
121816
121930
  }
121817
121931
  text = "";
121818
121932
  }
121819
- return text !== undefined ? ts.createSourceFile(fileName, text, languageVersion) : undefined;
121933
+ return text !== undefined ? ts.createSourceFile(fileName, text, languageVersionOrOptions) : undefined;
121820
121934
  },
121821
121935
  getDefaultLibLocation: ts.maybeBind(host, host.getDefaultLibLocation),
121822
121936
  getDefaultLibFileName: function (options) { return host.getDefaultLibFileName(options); },
@@ -122284,7 +122398,7 @@ var ts;
122284
122398
  }
122285
122399
  return directoryStructureHost.fileExists(fileName);
122286
122400
  }
122287
- function getVersionedSourceFileByPath(fileName, path, languageVersion, onError, shouldCreateNewSourceFile) {
122401
+ function getVersionedSourceFileByPath(fileName, path, languageVersionOrOptions, onError, shouldCreateNewSourceFile) {
122288
122402
  var hostSourceFile = sourceFilesCache.get(path);
122289
122403
  // No source file on the host
122290
122404
  if (isFileMissingOnHost(hostSourceFile)) {
@@ -122292,7 +122406,7 @@ var ts;
122292
122406
  }
122293
122407
  // Create new source file if requested or the versions dont match
122294
122408
  if (hostSourceFile === undefined || shouldCreateNewSourceFile || isFilePresenceUnknownOnHost(hostSourceFile)) {
122295
- var sourceFile = getNewSourceFile(fileName, languageVersion, onError);
122409
+ var sourceFile = getNewSourceFile(fileName, languageVersionOrOptions, onError);
122296
122410
  if (hostSourceFile) {
122297
122411
  if (sourceFile) {
122298
122412
  // Set the source file and create file watcher now that file was present on the disk
@@ -127327,14 +127441,6 @@ var ts;
127327
127441
  });
127328
127442
  }
127329
127443
  ts.signatureToDisplayParts = signatureToDisplayParts;
127330
- function nodeToDisplayParts(node, enclosingDeclaration) {
127331
- var file = enclosingDeclaration.getSourceFile();
127332
- return mapToDisplayParts(function (writer) {
127333
- var printer = ts.createPrinter({ removeComments: true, omitTrailingSemicolon: true });
127334
- printer.writeNode(4 /* Unspecified */, node, file, writer);
127335
- });
127336
- }
127337
- ts.nodeToDisplayParts = nodeToDisplayParts;
127338
127444
  function isImportOrExportSpecifierName(location) {
127339
127445
  return !!location.parent && ts.isImportOrExportSpecifier(location.parent) && location.parent.propertyName === location;
127340
127446
  }
@@ -130675,8 +130781,6 @@ var ts;
130675
130781
  CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
130676
130782
  /** A type-only import that needs to be promoted in order to be used at the completion location */
130677
130783
  CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
130678
- /** Auto-import that comes attached to an object literal method snippet */
130679
- CompletionSource["ObjectLiteralMethodSnippet"] = "ObjectLiteralMethodSnippet/";
130680
130784
  })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
130681
130785
  var SymbolOriginInfoKind;
130682
130786
  (function (SymbolOriginInfoKind) {
@@ -130687,7 +130791,6 @@ var ts;
130687
130791
  SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
130688
130792
  SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
130689
130793
  SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
130690
- SymbolOriginInfoKind[SymbolOriginInfoKind["ObjectLiteralMethod"] = 128] = "ObjectLiteralMethod";
130691
130794
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
130692
130795
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
130693
130796
  })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
@@ -130718,9 +130821,6 @@ var ts;
130718
130821
  function originIsTypeOnlyAlias(origin) {
130719
130822
  return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
130720
130823
  }
130721
- function originIsObjectLiteralMethod(origin) {
130722
- return !!(origin && origin.kind & 128 /* ObjectLiteralMethod */);
130723
- }
130724
130824
  var KeywordCompletionFilters;
130725
130825
  (function (KeywordCompletionFilters) {
130726
130826
  KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
@@ -131146,20 +131246,6 @@ var ts;
131146
131246
  source = CompletionSource.ClassMemberSnippet;
131147
131247
  }
131148
131248
  }
131149
- if (origin && originIsObjectLiteralMethod(origin)) {
131150
- var objectLiteral = ts.cast(tryGetObjectLikeCompletionContainer(contextToken), ts.isObjectLiteralExpression);
131151
- var importAdder = void 0;
131152
- var entry = getEntryForObjectLiteralMethodCompletion(symbol, name, objectLiteral, program, host, options, preferences, formatContext);
131153
- if (!entry) {
131154
- return undefined;
131155
- }
131156
- (insertText = entry.insertText, isSnippet = entry.isSnippet, importAdder = entry.importAdder, sourceDisplay = entry.sourceDisplay);
131157
- source = CompletionSource.ObjectLiteralMethodSnippet;
131158
- sortText = SortText.OptionalMember;
131159
- if (importAdder.hasFixes()) {
131160
- hasAction = true;
131161
- }
131162
- }
131163
131249
  if (isJsxIdentifierExpected && !isRightOfOpenTag && preferences.includeCompletionsWithSnippetText && preferences.jsxAttributeCompletionStyle && preferences.jsxAttributeCompletionStyle !== "none") {
131164
131250
  var useBraces_1 = preferences.jsxAttributeCompletionStyle === "braces";
131165
131251
  var type = typeChecker.getTypeOfSymbolAtLocation(symbol, location);
@@ -131318,15 +131404,27 @@ var ts;
131318
131404
  completionNodes.push(node);
131319
131405
  }, body, 2 /* Property */, isAbstract);
131320
131406
  if (completionNodes.length) {
131321
- var format = 1 /* MultiLine */ | 131072 /* NoTrailingNewLine */;
131322
131407
  replacementSpan = modifiersSpan;
131323
131408
  // If we have access to formatting settings, we print the nodes using the emitter,
131324
131409
  // and then format the printed text.
131325
131410
  if (formatContext) {
131326
- insertText = printer.printAndFormatSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile, formatContext);
131411
+ var syntheticFile_1 = {
131412
+ text: printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile),
131413
+ getLineAndCharacterOfPosition: function (pos) {
131414
+ return ts.getLineAndCharacterOfPosition(this, pos);
131415
+ },
131416
+ };
131417
+ var formatOptions_1 = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
131418
+ var changes = ts.flatMap(completionNodes, function (node) {
131419
+ var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
131420
+ return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile_1, sourceFile.languageVariant,
131421
+ /* indentation */ 0,
131422
+ /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions_1 }));
131423
+ });
131424
+ insertText = ts.textChanges.applyChanges(syntheticFile_1.text, changes);
131327
131425
  }
131328
131426
  else { // Otherwise, just use emitter to print the new nodes.
131329
- insertText = printer.printSnippetList(format, ts.factory.createNodeArray(completionNodes), sourceFile);
131427
+ insertText = printer.printSnippetList(1 /* MultiLine */ | 131072 /* NoTrailingNewLine */, ts.factory.createNodeArray(completionNodes), sourceFile);
131330
131428
  }
131331
131429
  }
131332
131430
  return { insertText: insertText, isSnippet: isSnippet, importAdder: importAdder, replacementSpan: replacementSpan };
@@ -131376,92 +131474,12 @@ var ts;
131376
131474
  }
131377
131475
  return undefined;
131378
131476
  }
131379
- function getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, options, preferences, formatContext) {
131380
- var isSnippet;
131381
- var insertText = name;
131382
- var sourceFile = enclosingDeclaration.getSourceFile();
131383
- var importAdder = ts.codefix.createImportAdder(sourceFile, program, preferences, host);
131384
- var body;
131385
- if (preferences.includeCompletionsWithSnippetText) {
131386
- isSnippet = true;
131387
- var emptyStmt = ts.factory.createEmptyStatement();
131388
- body = ts.factory.createBlock([emptyStmt], /* multiline */ true);
131389
- ts.setSnippetElement(emptyStmt, { kind: 0 /* TabStop */, order: 0 });
131390
- }
131391
- else {
131392
- body = ts.factory.createBlock([], /* multiline */ true);
131393
- }
131394
- var method = createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder, /*body*/ body);
131395
- if (!method) {
131396
- return undefined;
131397
- }
131398
- var printer = createSnippetPrinter({
131399
- removeComments: true,
131400
- module: options.module,
131401
- target: options.target,
131402
- omitTrailingSemicolon: false,
131403
- newLine: ts.getNewLineKind(ts.getNewLineCharacter(options, ts.maybeBind(host, host.getNewLine))),
131404
- });
131405
- if (formatContext) {
131406
- insertText = printer.printAndFormatSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile, formatContext);
131407
- }
131408
- else {
131409
- insertText = printer.printSnippetList(16 /* CommaDelimited */ | 64 /* AllowTrailingComma */, ts.factory.createNodeArray([method], /*hasTrailingComma*/ true), sourceFile);
131410
- }
131411
- var methodSignature = ts.factory.createMethodSignature(method.modifiers, method.name, method.questionToken, method.typeParameters, method.parameters, method.type);
131412
- var sourceDisplay = ts.nodeToDisplayParts(methodSignature, enclosingDeclaration);
131413
- return { isSnippet: isSnippet, insertText: insertText, importAdder: importAdder, sourceDisplay: sourceDisplay };
131414
- }
131415
- ;
131416
- function createObjectLiteralMethod(symbol, enclosingDeclaration, sourceFile, program, host, preferences, importAdder, body) {
131417
- var declarations = symbol.getDeclarations();
131418
- if (!(declarations && declarations.length)) {
131419
- return undefined;
131420
- }
131421
- var checker = program.getTypeChecker();
131422
- var scriptTarget = ts.getEmitScriptTarget(program.getCompilerOptions());
131423
- var declaration = declarations[0];
131424
- var name = ts.getSynthesizedDeepClone(ts.getNameOfDeclaration(declaration), /*includeTrivia*/ false);
131425
- var type = checker.getWidenedType(checker.getTypeOfSymbolAtLocation(symbol, enclosingDeclaration));
131426
- var quotePreference = ts.getQuotePreference(sourceFile, preferences);
131427
- var builderFlags = quotePreference === 0 /* Single */ ? 268435456 /* UseSingleQuotesForStringLiteralType */ : undefined;
131428
- switch (declaration.kind) {
131429
- case 165 /* PropertySignature */:
131430
- case 166 /* PropertyDeclaration */:
131431
- case 167 /* MethodSignature */:
131432
- case 168 /* MethodDeclaration */: {
131433
- var signatures = checker.getSignaturesOfType(type, 0 /* Call */);
131434
- if (signatures.length > 1) {
131435
- // We don't support overloads in object literals.
131436
- return undefined;
131437
- }
131438
- var typeNode = checker.typeToTypeNode(type, enclosingDeclaration, builderFlags, ts.codefix.getNoopSymbolTrackerWithResolver({ program: program, host: host }));
131439
- var importableReference = ts.codefix.tryGetAutoImportableReferenceFromTypeNode(typeNode, scriptTarget);
131440
- if (importableReference) {
131441
- typeNode = importableReference.typeNode;
131442
- ts.codefix.importSymbols(importAdder, importableReference.symbols);
131443
- }
131444
- if (!typeNode) {
131445
- return undefined;
131446
- }
131447
- ts.Debug.assertNode(typeNode, ts.isFunctionTypeNode);
131448
- return ts.factory.createMethodDeclaration(
131449
- /*decorators*/ undefined,
131450
- /*modifiers*/ undefined,
131451
- /*asteriskToken*/ undefined, name,
131452
- /*questionToken*/ undefined, typeNode.typeParameters, typeNode.parameters, typeNode.type, body);
131453
- }
131454
- default:
131455
- return undefined;
131456
- }
131457
- }
131458
131477
  function createSnippetPrinter(printerOptions) {
131459
131478
  var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
131460
131479
  var printer = ts.createPrinter(printerOptions, baseWriter);
131461
131480
  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)); } });
131462
131481
  return {
131463
131482
  printSnippetList: printSnippetList,
131464
- printAndFormatSnippetList: printAndFormatSnippetList,
131465
131483
  };
131466
131484
  /* Snippet-escaping version of `printer.printList`. */
131467
131485
  function printSnippetList(format, list, sourceFile) {
@@ -131469,22 +131487,6 @@ var ts;
131469
131487
  printer.writeList(format, list, sourceFile, writer);
131470
131488
  return writer.getText();
131471
131489
  }
131472
- function printAndFormatSnippetList(format, list, sourceFile, formatContext) {
131473
- var syntheticFile = {
131474
- text: printSnippetList(format, list, sourceFile),
131475
- getLineAndCharacterOfPosition: function (pos) {
131476
- return ts.getLineAndCharacterOfPosition(this, pos);
131477
- },
131478
- };
131479
- var formatOptions = ts.getFormatCodeSettingsForWriting(formatContext, sourceFile);
131480
- var changes = ts.flatMap(list, function (node) {
131481
- var nodeWithPos = ts.textChanges.assignPositionsToNode(node);
131482
- return ts.formatting.formatNodeGivenIndentation(nodeWithPos, syntheticFile, sourceFile.languageVariant,
131483
- /* indentation */ 0,
131484
- /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions }));
131485
- });
131486
- return ts.textChanges.applyChanges(syntheticFile.text, changes);
131487
- }
131488
131490
  }
131489
131491
  function originToCompletionEntryData(origin) {
131490
131492
  var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
@@ -131597,7 +131599,7 @@ var ts;
131597
131599
  var symbol = symbols[i];
131598
131600
  var origin = symbolToOriginInfoMap === null || symbolToOriginInfoMap === void 0 ? void 0 : symbolToOriginInfoMap[i];
131599
131601
  var info = getCompletionEntryDisplayNameForSymbol(symbol, target, origin, kind, !!jsxIdentifierExpected);
131600
- if (!info || (uniques.get(info.name) && (!origin || !originIsObjectLiteralMethod(origin))) || kind === 1 /* Global */ && symbolToSortTextIdMap && !shouldIncludeSymbol(symbol, symbolToSortTextIdMap)) {
131602
+ if (!info || uniques.get(info.name) || kind === 1 /* Global */ && symbolToSortTextIdMap && !shouldIncludeSymbol(symbol, symbolToSortTextIdMap)) {
131601
131603
  continue;
131602
131604
  }
131603
131605
  var name = info.name, needsConvertPropertyAccess = info.needsConvertPropertyAccess;
@@ -131728,9 +131730,7 @@ var ts;
131728
131730
  return ts.firstDefined(symbols, function (symbol, index) {
131729
131731
  var origin = symbolToOriginInfoMap[index];
131730
131732
  var info = getCompletionEntryDisplayNameForSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), origin, completionKind, completionData.isJsxIdentifierExpected);
131731
- return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */
131732
- || entryId.source === CompletionSource.ObjectLiteralMethodSnippet && symbol.flags & (4 /* Property */ | 8192 /* Method */)
131733
- || getSourceFromOrigin(origin) === entryId.source)
131733
+ return info && info.name === entryId.name && (entryId.source === CompletionSource.ClassMemberSnippet && symbol.flags & 106500 /* ClassMember */ || getSourceFromOrigin(origin) === entryId.source)
131734
131734
  ? { type: "symbol", symbol: symbol, location: location, origin: origin, contextToken: contextToken, previousToken: previousToken, isJsxInitializer: isJsxInitializer, isTypeOnlyLocation: isTypeOnlyLocation }
131735
131735
  : undefined;
131736
131736
  }) || { type: "none" };
@@ -131812,20 +131812,6 @@ var ts;
131812
131812
  };
131813
131813
  }
131814
131814
  }
131815
- if (source === CompletionSource.ObjectLiteralMethodSnippet) {
131816
- var enclosingDeclaration = tryGetObjectLikeCompletionContainer(contextToken);
131817
- var importAdder = getEntryForObjectLiteralMethodCompletion(symbol, name, enclosingDeclaration, program, host, compilerOptions, preferences, formatContext).importAdder;
131818
- if (importAdder.hasFixes()) {
131819
- var changes = ts.textChanges.ChangeTracker.with({ host: host, formatContext: formatContext, preferences: preferences }, importAdder.writeFixes);
131820
- return {
131821
- sourceDisplay: undefined,
131822
- codeActions: [{
131823
- changes: changes,
131824
- description: ts.diagnosticToString([ts.Diagnostics.Includes_imports_of_types_referenced_by_0, name]),
131825
- }],
131826
- };
131827
- }
131828
- }
131829
131815
  if (originIsTypeOnlyAlias(origin)) {
131830
131816
  var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
131831
131817
  ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
@@ -132712,45 +132698,6 @@ var ts;
132712
132698
  symbolToSortTextIdMap[symbolId] = importCompletionNode ? 11 /* LocationPriority */ : 16 /* AutoImportSuggestions */;
132713
132699
  symbols.push(symbol);
132714
132700
  }
132715
- /* Mutates `symbols` and `symbolToOriginInfoMap`. */
132716
- function collectObjectLiteralMethodSymbols(members) {
132717
- // TODO: support JS files.
132718
- if (ts.isInJSFile(location)) {
132719
- return;
132720
- }
132721
- members = members.slice(); // Needed in case `symbol` and `members` are the same array.
132722
- for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
132723
- var member = members_1[_i];
132724
- if (!isObjectLiteralMethodSymbol(member)) {
132725
- continue;
132726
- }
132727
- var origin = { kind: 128 /* ObjectLiteralMethod */ };
132728
- symbolToOriginInfoMap[symbols.length] = origin;
132729
- symbols.push(member);
132730
- }
132731
- }
132732
- function isObjectLiteralMethodSymbol(symbol) {
132733
- /*
132734
- For an object type
132735
- `type Foo = {
132736
- bar(x: number): void;
132737
- foo: (x: string) => string;
132738
- }`,
132739
- `bar` will have symbol flag `Method`,
132740
- `foo` will have symbol flag `Property`.
132741
- */
132742
- if (!(symbol.flags & (4 /* Property */ | 8192 /* Method */))) {
132743
- return false;
132744
- }
132745
- if (symbol.flags & 4 /* Property */) {
132746
- var type = program.getTypeChecker().getTypeOfSymbol(symbol);
132747
- // We ignore non-function properties.
132748
- if (!type.getCallSignatures().length) {
132749
- return false;
132750
- }
132751
- }
132752
- return true;
132753
- }
132754
132701
  /**
132755
132702
  * Finds the first node that "embraces" the position, so that one may
132756
132703
  * accurately aggregate locals from the closest containing scope.
@@ -132948,11 +132895,7 @@ var ts;
132948
132895
  }
132949
132896
  if (typeMembers && typeMembers.length > 0) {
132950
132897
  // Add filtered items to the completion list
132951
- var filteredMembers = filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers));
132952
- symbols = ts.concatenate(symbols, filteredMembers);
132953
- if (objectLikeContainer.kind === 204 /* ObjectLiteralExpression */ && preferences.includeCompletionsWithInsertText) {
132954
- collectObjectLiteralMethodSymbols(filteredMembers);
132955
- }
132898
+ symbols = ts.concatenate(symbols, filterObjectMembersList(typeMembers, ts.Debug.checkDefined(existingMembers)));
132956
132899
  }
132957
132900
  setSortTextToOptionalMember();
132958
132901
  return 1 /* Success */;
@@ -133084,6 +133027,29 @@ var ts;
133084
133027
  }
133085
133028
  return 1 /* Success */;
133086
133029
  }
133030
+ /**
133031
+ * Returns the immediate owning object literal or binding pattern of a context token,
133032
+ * on the condition that one exists and that the context implies completion should be given.
133033
+ */
133034
+ function tryGetObjectLikeCompletionContainer(contextToken) {
133035
+ if (contextToken) {
133036
+ var parent = contextToken.parent;
133037
+ switch (contextToken.kind) {
133038
+ case 18 /* OpenBraceToken */: // const x = { |
133039
+ case 27 /* CommaToken */: // const x = { a: 0, |
133040
+ if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
133041
+ return parent;
133042
+ }
133043
+ break;
133044
+ case 41 /* AsteriskToken */:
133045
+ return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
133046
+ case 79 /* Identifier */:
133047
+ return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
133048
+ ? contextToken.parent.parent : undefined;
133049
+ }
133050
+ }
133051
+ return undefined;
133052
+ }
133087
133053
  function isConstructorParameterCompletion(node) {
133088
133054
  return !!node.parent && ts.isParameter(node.parent) && ts.isConstructorDeclaration(node.parent.parent)
133089
133055
  && (ts.isParameterPropertyModifier(node.kind) || ts.isDeclarationName(node));
@@ -133506,29 +133472,6 @@ var ts;
133506
133472
  return node.getStart(sourceFile) <= position && position <= node.getEnd();
133507
133473
  }
133508
133474
  }
133509
- /**
133510
- * Returns the immediate owning object literal or binding pattern of a context token,
133511
- * on the condition that one exists and that the context implies completion should be given.
133512
- */
133513
- function tryGetObjectLikeCompletionContainer(contextToken) {
133514
- if (contextToken) {
133515
- var parent = contextToken.parent;
133516
- switch (contextToken.kind) {
133517
- case 18 /* OpenBraceToken */: // const x = { |
133518
- case 27 /* CommaToken */: // const x = { a: 0, |
133519
- if (ts.isObjectLiteralExpression(parent) || ts.isObjectBindingPattern(parent)) {
133520
- return parent;
133521
- }
133522
- break;
133523
- case 41 /* AsteriskToken */:
133524
- return ts.isMethodDeclaration(parent) ? ts.tryCast(parent.parent, ts.isObjectLiteralExpression) : undefined;
133525
- case 79 /* Identifier */:
133526
- return contextToken.text === "async" && ts.isShorthandPropertyAssignment(contextToken.parent)
133527
- ? contextToken.parent.parent : undefined;
133528
- }
133529
- }
133530
- return undefined;
133531
- }
133532
133475
  function getRelevantTokens(position, sourceFile) {
133533
133476
  var previousToken = ts.findPrecedingToken(position, sourceFile);
133534
133477
  if (previousToken && position <= previousToken.end && (ts.isMemberName(previousToken) || ts.isKeyword(previousToken.kind))) {
@@ -134568,9 +134511,15 @@ var ts;
134568
134511
  });
134569
134512
  return JSON.stringify(bucketInfoArray, undefined, 2);
134570
134513
  }
134514
+ function getCompilationSettings(settingsOrHost) {
134515
+ if (typeof settingsOrHost.getCompilationSettings === "function") {
134516
+ return settingsOrHost.getCompilationSettings();
134517
+ }
134518
+ return settingsOrHost;
134519
+ }
134571
134520
  function acquireDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
134572
134521
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
134573
- var key = getKeyForCompilationSettings(compilationSettings);
134522
+ var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
134574
134523
  return acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
134575
134524
  }
134576
134525
  function acquireDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
@@ -134578,20 +134527,28 @@ var ts;
134578
134527
  }
134579
134528
  function updateDocument(fileName, compilationSettings, scriptSnapshot, version, scriptKind) {
134580
134529
  var path = ts.toPath(fileName, currentDirectory, getCanonicalFileName);
134581
- var key = getKeyForCompilationSettings(compilationSettings);
134530
+ var key = getKeyForCompilationSettings(getCompilationSettings(compilationSettings));
134582
134531
  return updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind);
134583
134532
  }
134584
134533
  function updateDocumentWithKey(fileName, path, compilationSettings, key, scriptSnapshot, version, scriptKind) {
134585
- return acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
134534
+ return acquireOrUpdateDocument(fileName, path, getCompilationSettings(compilationSettings), key, scriptSnapshot, version, /*acquiring*/ false, scriptKind);
134586
134535
  }
134587
134536
  function getDocumentRegistryEntry(bucketEntry, scriptKind) {
134588
134537
  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"));
134589
134538
  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);
134590
134539
  return entry;
134591
134540
  }
134592
- function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) {
134541
+ function acquireOrUpdateDocument(fileName, path, compilationSettingsOrHost, key, scriptSnapshot, version, acquiring, scriptKind) {
134542
+ var _a, _b, _c, _d;
134593
134543
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
134544
+ var compilationSettings = getCompilationSettings(compilationSettingsOrHost);
134545
+ var host = compilationSettingsOrHost === compilationSettings ? undefined : compilationSettingsOrHost;
134594
134546
  var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
134547
+ var sourceFileOptions = {
134548
+ languageVersion: scriptTarget,
134549
+ 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),
134550
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(compilationSettings)
134551
+ };
134595
134552
  var oldBucketCount = buckets.size;
134596
134553
  var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
134597
134554
  if (ts.tracing) {
@@ -134625,7 +134582,7 @@ var ts;
134625
134582
  }
134626
134583
  if (!entry) {
134627
134584
  // Have never seen this file with these settings. Create a new source file for it.
134628
- var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, /*setNodeParents*/ false, scriptKind);
134585
+ var sourceFile = ts.createLanguageServiceSourceFile(fileName, scriptSnapshot, sourceFileOptions, version, /*setNodeParents*/ false, scriptKind);
134629
134586
  if (externalCache) {
134630
134587
  externalCache.setDocument(key, path, sourceFile);
134631
134588
  }
@@ -141559,6 +141516,41 @@ var ts;
141559
141516
  if (ts.scanner.getToken() === 1 /* EndOfFileToken */) {
141560
141517
  break;
141561
141518
  }
141519
+ if (ts.scanner.getToken() === 15 /* TemplateHead */) {
141520
+ var stack = [ts.scanner.getToken()];
141521
+ var token = ts.scanner.scan();
141522
+ loop: while (ts.length(stack)) {
141523
+ switch (token) {
141524
+ case 1 /* EndOfFileToken */:
141525
+ break loop;
141526
+ case 100 /* ImportKeyword */:
141527
+ tryConsumeImport();
141528
+ break;
141529
+ case 15 /* TemplateHead */:
141530
+ stack.push(token);
141531
+ break;
141532
+ case 18 /* OpenBraceToken */:
141533
+ if (ts.length(stack)) {
141534
+ stack.push(token);
141535
+ }
141536
+ break;
141537
+ case 19 /* CloseBraceToken */:
141538
+ if (ts.length(stack)) {
141539
+ if (ts.lastOrUndefined(stack) === 15 /* TemplateHead */) {
141540
+ if (ts.scanner.reScanTemplateToken(/* isTaggedTemplate */ false) === 17 /* TemplateTail */) {
141541
+ stack.pop();
141542
+ }
141543
+ }
141544
+ else {
141545
+ stack.pop();
141546
+ }
141547
+ }
141548
+ break;
141549
+ }
141550
+ token = ts.scanner.scan();
141551
+ }
141552
+ nextToken();
141553
+ }
141562
141554
  // check if at least one of alternative have moved scanner forward
141563
141555
  if (tryConsumeDeclare() ||
141564
141556
  tryConsumeImport() ||
@@ -143069,7 +143061,7 @@ var ts;
143069
143061
  continue;
143070
143062
  var module_1 = ts.getResolvedModule(sourceFile, moduleSpecifier.text, ts.getModeForUsageLocation(sourceFile, moduleSpecifier));
143071
143063
  var resolvedFile = module_1 && program.getSourceFile(module_1.resolvedFileName);
143072
- if (resolvedFile && resolvedFile.externalModuleIndicator && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
143064
+ if (resolvedFile && resolvedFile.externalModuleIndicator && resolvedFile.externalModuleIndicator !== true && ts.isExportAssignment(resolvedFile.externalModuleIndicator) && resolvedFile.externalModuleIndicator.isExportEquals) {
143073
143065
  diags.push(ts.createDiagnosticForNode(name, ts.Diagnostics.Import_may_be_converted_to_a_default_import));
143074
143066
  }
143075
143067
  }
@@ -143985,19 +143977,7 @@ var ts;
143985
143977
  options.suppressOutputPathCheck = true;
143986
143978
  // Filename can be non-ts file.
143987
143979
  options.allowNonTsExtensions = true;
143988
- // if jsx is specified then treat file as .tsx
143989
- var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts");
143990
- var sourceFile = ts.createSourceFile(inputFileName, input, ts.getEmitScriptTarget(options));
143991
- if (transpileOptions.moduleName) {
143992
- sourceFile.moduleName = transpileOptions.moduleName;
143993
- }
143994
- if (transpileOptions.renamedDependencies) {
143995
- sourceFile.renamedDependencies = new ts.Map(ts.getEntries(transpileOptions.renamedDependencies));
143996
- }
143997
143980
  var newLine = ts.getNewLineCharacter(options);
143998
- // Output
143999
- var outputText;
144000
- var sourceMapText;
144001
143981
  // Create a compilerHost object to allow the compiler to read and write files
144002
143982
  var compilerHost = {
144003
143983
  getSourceFile: function (fileName) { return fileName === ts.normalizePath(inputFileName) ? sourceFile : undefined; },
@@ -144021,6 +144001,22 @@ var ts;
144021
144001
  directoryExists: function () { return true; },
144022
144002
  getDirectories: function () { return []; }
144023
144003
  };
144004
+ // if jsx is specified then treat file as .tsx
144005
+ var inputFileName = transpileOptions.fileName || (transpileOptions.compilerOptions && transpileOptions.compilerOptions.jsx ? "module.tsx" : "module.ts");
144006
+ var sourceFile = ts.createSourceFile(inputFileName, input, {
144007
+ languageVersion: ts.getEmitScriptTarget(options),
144008
+ impliedNodeFormat: ts.getImpliedNodeFormatForFile(ts.toPath(inputFileName, "", compilerHost.getCanonicalFileName), /*cache*/ undefined, compilerHost, options),
144009
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(options)
144010
+ });
144011
+ if (transpileOptions.moduleName) {
144012
+ sourceFile.moduleName = transpileOptions.moduleName;
144013
+ }
144014
+ if (transpileOptions.renamedDependencies) {
144015
+ sourceFile.renamedDependencies = new ts.Map(ts.getEntries(transpileOptions.renamedDependencies));
144016
+ }
144017
+ // Output
144018
+ var outputText;
144019
+ var sourceMapText;
144024
144020
  var program = ts.createProgram([inputFileName], options, compilerHost);
144025
144021
  if (transpileOptions.reportDiagnostics) {
144026
144022
  ts.addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile));
@@ -155926,7 +155922,6 @@ var ts;
155926
155922
  if (!ts.some(signatures)) {
155927
155923
  break;
155928
155924
  }
155929
- // >> TODO: call `try get auto importable reference from type node` on type nodes?
155930
155925
  if (declarations.length === 1) {
155931
155926
  ts.Debug.assert(signatures.length === 1, "One declaration implies one signature");
155932
155927
  var signature = signatures[0];
@@ -155957,27 +155952,6 @@ var ts;
155957
155952
  }
155958
155953
  }
155959
155954
  codefix.addNewNodeForMemberSymbol = addNewNodeForMemberSymbol;
155960
- // export function addNewNodeObjectLiteralProperties(
155961
- // // changes: textChanges.ChangeTracker,
155962
- // // context: CodeFixContextBase,
155963
- // sourceFile: SourceFile,
155964
- // program: Program,
155965
- // preferences: UserPreferences,
155966
- // host: LanguageServiceHost,
155967
- // // info: ObjectLiteralInfo,
155968
- // properties: Symbol[],
155969
- // addNodes: (nodes: PropertyAssignment[]) => void,
155970
- // ): void {
155971
- // const importAdder = createImportAdder(sourceFile, program, preferences, host);
155972
- // const quotePreference = getQuotePreference(sourceFile, preferences);
155973
- // const target = getEmitScriptTarget(program.getCompilerOptions());
155974
- // const checker = program.getTypeChecker();
155975
- // const props = map(properties, prop => {
155976
- // const initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop));
155977
- // return factory.createPropertyAssignment(createPropertyNameNodeForIdentifierOrLiteral(prop.name, target, quotePreference === QuotePreference.Single), initializer);
155978
- // });
155979
- // addNodes(props);
155980
- // }
155981
155955
  function createSignatureDeclarationFromSignature(kind, context, quotePreference, signature, body, name, modifiers, optional, enclosingDeclaration, importAdder) {
155982
155956
  var program = context.program;
155983
155957
  var checker = program.getTypeChecker();
@@ -156147,7 +156121,6 @@ var ts;
156147
156121
  return createStubbedMethod(modifiers, name, optional,
156148
156122
  /*typeParameters*/ undefined, parameters, getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration), quotePreference, body);
156149
156123
  }
156150
- codefix.createMethodImplementingSignatures = createMethodImplementingSignatures;
156151
156124
  function getReturnTypeFromSignatures(signatures, checker, context, enclosingDeclaration) {
156152
156125
  if (ts.length(signatures)) {
156153
156126
  var type = checker.getUnionType(ts.map(signatures, checker.getReturnTypeOfSignature));
@@ -159375,8 +159348,8 @@ var ts;
159375
159348
  ts.Debug.assert(members.length > 0, "Found no members"); // There must be at least one child, since we extracted from one.
159376
159349
  var prevMember;
159377
159350
  var allProperties = true;
159378
- for (var _i = 0, members_2 = members; _i < members_2.length; _i++) {
159379
- var member = members_2[_i];
159351
+ for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
159352
+ var member = members_1[_i];
159380
159353
  if (member.pos > maxPos) {
159381
159354
  return prevMember || members[0];
159382
159355
  }
@@ -160556,7 +160529,7 @@ var ts;
160556
160529
  for (var i = 1;; i++) {
160557
160530
  var name = ts.combinePaths(inDirectory, newModuleName + extension);
160558
160531
  if (!host.fileExists(name))
160559
- return newModuleName; // TODO: GH#18217
160532
+ return newModuleName;
160560
160533
  newModuleName = moduleName + "." + i;
160561
160534
  }
160562
160535
  }
@@ -162916,6 +162889,7 @@ var ts;
162916
162889
  this.host = host;
162917
162890
  }
162918
162891
  SyntaxTreeCache.prototype.getCurrentSourceFile = function (fileName) {
162892
+ var _a, _b, _c, _d, _e, _f, _g, _h;
162919
162893
  var scriptSnapshot = this.host.getScriptSnapshot(fileName);
162920
162894
  if (!scriptSnapshot) {
162921
162895
  // The host does not know about this file.
@@ -162926,7 +162900,12 @@ var ts;
162926
162900
  var sourceFile;
162927
162901
  if (this.currentFileName !== fileName) {
162928
162902
  // This is a new file, just parse it
162929
- sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, 99 /* Latest */, version, /*setNodeParents*/ true, scriptKind);
162903
+ var options = {
162904
+ languageVersion: 99 /* Latest */,
162905
+ 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()),
162906
+ setExternalModuleIndicator: ts.getSetExternalModuleIndicator(this.host.getCompilationSettings())
162907
+ };
162908
+ sourceFile = createLanguageServiceSourceFile(fileName, scriptSnapshot, options, version, /*setNodeParents*/ true, scriptKind);
162930
162909
  }
162931
162910
  else if (this.currentFileVersion !== version) {
162932
162911
  // This is the same file, just a newer version. Incrementally parse the file.
@@ -162948,8 +162927,8 @@ var ts;
162948
162927
  sourceFile.version = version;
162949
162928
  sourceFile.scriptSnapshot = scriptSnapshot;
162950
162929
  }
162951
- function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTarget, version, setNodeParents, scriptKind) {
162952
- var sourceFile = ts.createSourceFile(fileName, ts.getSnapshotText(scriptSnapshot), scriptTarget, setNodeParents, scriptKind);
162930
+ function createLanguageServiceSourceFile(fileName, scriptSnapshot, scriptTargetOrOptions, version, setNodeParents, scriptKind) {
162931
+ var sourceFile = ts.createSourceFile(fileName, ts.getSnapshotText(scriptSnapshot), scriptTargetOrOptions, setNodeParents, scriptKind);
162953
162932
  setSourceFileFields(sourceFile, scriptSnapshot, version);
162954
162933
  return sourceFile;
162955
162934
  }
@@ -162997,8 +162976,13 @@ var ts;
162997
162976
  return newSourceFile;
162998
162977
  }
162999
162978
  }
162979
+ var options = {
162980
+ languageVersion: sourceFile.languageVersion,
162981
+ impliedNodeFormat: sourceFile.impliedNodeFormat,
162982
+ setExternalModuleIndicator: sourceFile.setExternalModuleIndicator,
162983
+ };
163000
162984
  // Otherwise, just create a new source file.
163001
- return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, sourceFile.languageVersion, version, /*setNodeParents*/ true, sourceFile.scriptKind);
162985
+ return createLanguageServiceSourceFile(sourceFile.fileName, scriptSnapshot, options, version, /*setNodeParents*/ true, sourceFile.scriptKind);
163002
162986
  }
163003
162987
  ts.updateLanguageServiceSourceFile = updateLanguageServiceSourceFile;
163004
162988
  var NoopCancellationToken = {
@@ -163342,7 +163326,7 @@ var ts;
163342
163326
  // file's script kind, i.e. in one project some file is treated as ".ts"
163343
163327
  // and in another as ".js"
163344
163328
  if (hostFileInformation.scriptKind === oldSourceFile.scriptKind) {
163345
- return documentRegistry.updateDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
163329
+ return documentRegistry.updateDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
163346
163330
  }
163347
163331
  else {
163348
163332
  // Release old source file and fall through to aquire new file with new script kind
@@ -163352,7 +163336,7 @@ var ts;
163352
163336
  // We didn't already have the file. Fall through and acquire it from the registry.
163353
163337
  }
163354
163338
  // Could not find this file in the old program, create a new SourceFile for it.
163355
- return documentRegistry.acquireDocumentWithKey(fileName, path, newSettings, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
163339
+ return documentRegistry.acquireDocumentWithKey(fileName, path, host, documentRegistryBucketKey, hostFileInformation.scriptSnapshot, hostFileInformation.version, hostFileInformation.scriptKind);
163356
163340
  }
163357
163341
  }
163358
163342
  // TODO: GH#18217 frequently asserted as defined
@@ -168482,6 +168466,10 @@ var ts;
168482
168466
  this.packageJsonsForAutoImport = new ts.Set(packageJsons.map(function (p) { return p.fileName; }));
168483
168467
  return packageJsons;
168484
168468
  };
168469
+ /* @internal */
168470
+ Project.prototype.getPackageJsonCache = function () {
168471
+ return this.projectService.packageJsonCache;
168472
+ };
168485
168473
  /*@internal*/
168486
168474
  Project.prototype.getCachedExportInfoMap = function () {
168487
168475
  return this.exportMapCache || (this.exportMapCache = ts.createCacheableExportInfoMap(this));