typescript 4.6.0-dev.20220115 → 4.6.0-dev.20220119

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-dev.20220115";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220119";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -44691,7 +44691,7 @@ var ts;
44691
44691
  maybeBindExpressionFlowIfCall(node.expression);
44692
44692
  }
44693
44693
  function maybeBindExpressionFlowIfCall(node) {
44694
- // A top level or LHS of comma expression call expression with a dotted function name and at least one argument
44694
+ // A top level or comma expression call expression with a dotted function name and at least one argument
44695
44695
  // is potentially an assertion and is therefore included in the control flow.
44696
44696
  if (node.kind === 207 /* CallExpression */) {
44697
44697
  var call = node;
@@ -44859,22 +44859,27 @@ var ts;
44859
44859
  }
44860
44860
  return state;
44861
44861
  }
44862
- function onLeft(left, state, _node) {
44862
+ function onLeft(left, state, node) {
44863
44863
  if (!state.skip) {
44864
- return maybeBind(left);
44864
+ var maybeBound = maybeBind(left);
44865
+ if (node.operatorToken.kind === 27 /* CommaToken */) {
44866
+ maybeBindExpressionFlowIfCall(left);
44867
+ }
44868
+ return maybeBound;
44865
44869
  }
44866
44870
  }
44867
- function onOperator(operatorToken, state, node) {
44871
+ function onOperator(operatorToken, state, _node) {
44868
44872
  if (!state.skip) {
44869
- if (operatorToken.kind === 27 /* CommaToken */) {
44870
- maybeBindExpressionFlowIfCall(node.left);
44871
- }
44872
44873
  bind(operatorToken);
44873
44874
  }
44874
44875
  }
44875
- function onRight(right, state, _node) {
44876
+ function onRight(right, state, node) {
44876
44877
  if (!state.skip) {
44877
- return maybeBind(right);
44878
+ var maybeBound = maybeBind(right);
44879
+ if (node.operatorToken.kind === 27 /* CommaToken */) {
44880
+ maybeBindExpressionFlowIfCall(right);
44881
+ }
44882
+ return maybeBound;
44878
44883
  }
44879
44884
  }
44880
44885
  function onExit(node, state) {
@@ -51151,6 +51156,7 @@ var ts;
51151
51156
  getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
51152
51157
  getCurrentDirectory: function () { return host.getCurrentDirectory(); },
51153
51158
  getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
51159
+ getPackageJsonInfoCache: function () { var _a; return (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host); },
51154
51160
  useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
51155
51161
  redirectTargetsMap: host.redirectTargetsMap,
51156
51162
  getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
@@ -95723,10 +95729,19 @@ var ts;
95723
95729
  var _a;
95724
95730
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95725
95731
  var isStaticChildren = ts.length(nonWhitespaceChildren) > 1 || !!((_a = nonWhitespaceChildren[0]) === null || _a === void 0 ? void 0 : _a.dotDotDotToken);
95726
- var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)];
95732
+ var args = [tagName, objectProperties];
95733
+ // function jsx(type, config, maybeKey) {}
95734
+ // "maybeKey" is optional. It is acceptable to use "_jsx" without a third argument
95735
+ if (keyAttr) {
95736
+ args.push(transformJsxAttributeInitializer(keyAttr.initializer));
95737
+ }
95727
95738
  if (compilerOptions.jsx === 5 /* ReactJSXDev */) {
95728
95739
  var originalFile = ts.getOriginalNode(currentSourceFile);
95729
95740
  if (originalFile && ts.isSourceFile(originalFile)) {
95741
+ // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature
95742
+ if (keyAttr === undefined) {
95743
+ args.push(factory.createVoidZero());
95744
+ }
95730
95745
  // isStaticChildren development flag
95731
95746
  args.push(isStaticChildren ? factory.createTrue() : factory.createFalse());
95732
95747
  // __source development flag
@@ -119591,11 +119606,12 @@ var ts;
119591
119606
  };
119592
119607
  }
119593
119608
  function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) {
119609
+ var _a;
119594
119610
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12
119595
119611
  && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
119596
119612
  return false;
119597
119613
  }
119598
- return ts.getImpliedNodeFormatForFile(importingSourceFileName, /*packageJsonInfoCache*/ undefined, getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
119614
+ return ts.getImpliedNodeFormatForFile(importingSourceFileName, (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host), getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
119599
119615
  }
119600
119616
  function getModuleResolutionHost(host) {
119601
119617
  var _a;
@@ -120155,11 +120171,13 @@ var ts;
120155
120171
  // For classic resolution, only allow importing from node_modules/@types, not other node_modules
120156
120172
  return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName;
120157
120173
  function tryDirectoryWithPackageJson(packageRootIndex) {
120174
+ var _a, _b;
120158
120175
  var packageRootPath = path.substring(0, packageRootIndex);
120159
120176
  var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
120160
120177
  var moduleFileToTry = path;
120161
- if (host.fileExists(packageJsonPath)) {
120162
- var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
120178
+ var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
120179
+ if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
120180
+ var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
120163
120181
  if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
120164
120182
  // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
120165
120183
  // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
@@ -120998,6 +121016,7 @@ var ts;
120998
121016
  var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
120999
121017
  var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
121000
121018
  var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
121019
+ var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
121001
121020
  var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
121002
121021
  var missingFilePathsRequestedForRelease; // These paths are held temporarily so that we can remove the entry from source file cache if the file is not tracked by missing files
121003
121022
  var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations
@@ -121160,14 +121179,21 @@ var ts;
121160
121179
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution);
121161
121180
  if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
121162
121181
  if (hasChangedConfigFileParsingErrors) {
121182
+ if (reportFileChangeDetectedOnCreateProgram) {
121183
+ reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
121184
+ }
121163
121185
  builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
121164
121186
  hasChangedConfigFileParsingErrors = false;
121165
121187
  }
121166
121188
  }
121167
121189
  else {
121190
+ if (reportFileChangeDetectedOnCreateProgram) {
121191
+ reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
121192
+ }
121168
121193
  createNewProgram(hasInvalidatedResolution);
121169
121194
  }
121170
121195
  changesAffectResolution = false; // reset for next sync
121196
+ reportFileChangeDetectedOnCreateProgram = false;
121171
121197
  if (host.afterProgramCreate && program !== builderProgram) {
121172
121198
  host.afterProgramCreate(builderProgram);
121173
121199
  }
@@ -121369,7 +121395,7 @@ var ts;
121369
121395
  }
121370
121396
  function updateProgramWithWatchStatus() {
121371
121397
  timerToUpdateProgram = undefined;
121372
- reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
121398
+ reportFileChangeDetectedOnCreateProgram = true;
121373
121399
  updateProgram();
121374
121400
  }
121375
121401
  function updateProgram() {
@@ -123893,6 +123919,7 @@ var ts;
123893
123919
  ScriptElementKind["externalModuleName"] = "external module name";
123894
123920
  /**
123895
123921
  * <JsxTagName attribute1 attribute2={0} />
123922
+ * @deprecated
123896
123923
  */
123897
123924
  ScriptElementKind["jsxAttribute"] = "JSX attribute";
123898
123925
  /** String literal */
@@ -125784,6 +125811,7 @@ var ts;
125784
125811
  useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
125785
125812
  getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache) || program.getSymlinkCache,
125786
125813
  getModuleSpecifierCache: ts.maybeBind(host, host.getModuleSpecifierCache),
125814
+ getPackageJsonInfoCache: function () { var _a; return (_a = program.getModuleResolutionCache()) === null || _a === void 0 ? void 0 : _a.getPackageJsonInfoCache(); },
125787
125815
  getGlobalTypingsCacheLocation: ts.maybeBind(host, host.getGlobalTypingsCacheLocation),
125788
125816
  redirectTargetsMap: program.redirectTargetsMap,
125789
125817
  getProjectReferenceRedirect: function (fileName) { return program.getProjectReferenceRedirect(fileName); },
@@ -129528,6 +129556,7 @@ var ts;
129528
129556
  function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) {
129529
129557
  var _a, _b, _c;
129530
129558
  var start = ts.timestamp();
129559
+ var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
129531
129560
  var resolutionLimitExceeded = false;
129532
129561
  var ambientCount = 0;
129533
129562
  var resolvedCount = 0;
@@ -129550,7 +129579,7 @@ var ts;
129550
129579
  var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
129551
129580
  var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
129552
129581
  var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
129553
- ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, shouldGetModuleSpecifierFromCache)
129582
+ ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
129554
129583
  : undefined;
129555
129584
  if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
129556
129585
  resolutionLimitExceeded = true;
@@ -130948,9 +130977,7 @@ var ts;
130948
130977
  // GH#39946. Pulling on the type of a node inside of a function with a contextual `this` parameter can result in a circularity
130949
130978
  // if the `node` is part of the exprssion of a `yield` or `return`. This circularity doesn't exist at compile time because
130950
130979
  // we will check (and cache) the type of `this` *before* checking the type of the node.
130951
- var container = ts.getThisContainer(node, /*includeArrowFunctions*/ false);
130952
- if (!ts.isSourceFile(container) && container.parent)
130953
- typeChecker.getTypeAtLocation(container);
130980
+ typeChecker.tryGetThisTypeAt(node, /*includeGlobalThis*/ false);
130954
130981
  var type = typeChecker.getTypeAtLocation(node).getNonOptionalType();
130955
130982
  var insertQuestionDot = false;
130956
130983
  if (type.isNullableType()) {
@@ -141820,18 +141847,7 @@ var ts;
141820
141847
  }
141821
141848
  return unionPropertyKind;
141822
141849
  }
141823
- // If we requested completions after `x.` at the top-level, we may be at a source file location.
141824
- switch (location.parent && location.parent.kind) {
141825
- // If we've typed a character of the attribute name, will be 'JsxAttribute', else will be 'JsxOpeningElement'.
141826
- case 279 /* JsxOpeningElement */:
141827
- case 277 /* JsxElement */:
141828
- case 278 /* JsxSelfClosingElement */:
141829
- return location.kind === 79 /* Identifier */ ? "property" /* memberVariableElement */ : "JSX attribute" /* jsxAttribute */;
141830
- case 284 /* JsxAttribute */:
141831
- return "JSX attribute" /* jsxAttribute */;
141832
- default:
141833
- return "property" /* memberVariableElement */;
141834
- }
141850
+ return "property" /* memberVariableElement */;
141835
141851
  }
141836
141852
  return "" /* unknown */;
141837
141853
  }
@@ -145849,7 +145865,11 @@ var ts;
145849
145865
  oldTags[i] = merged;
145850
145866
  return !!merged;
145851
145867
  }); });
145852
- var tag = ts.factory.createJSDocComment(ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n"))), ts.factory.createNodeArray(__spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true)));
145868
+ var tags = __spreadArray(__spreadArray([], oldTags, true), unmergedNewTags, true);
145869
+ var jsDoc = ts.singleOrUndefined(parent.jsDoc);
145870
+ var comment = jsDoc && ts.positionsAreOnSameLine(jsDoc.pos, jsDoc.end, sourceFile) && !ts.length(comments) ? undefined :
145871
+ ts.factory.createNodeArray(ts.intersperse(comments, ts.factory.createJSDocText("\n")));
145872
+ var tag = ts.factory.createJSDocComment(comment, ts.factory.createNodeArray(tags));
145853
145873
  var host = updateJSDocHost(parent);
145854
145874
  this.insertJsdocCommentBefore(sourceFile, host, tag);
145855
145875
  };
@@ -146279,6 +146299,8 @@ var ts;
146279
146299
  }
146280
146300
  case 339 /* JSDocReturnTag */:
146281
146301
  return ts.factory.createJSDocReturnTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
146302
+ case 341 /* JSDocTypeTag */:
146303
+ return ts.factory.createJSDocTypeTag(/*tagName*/ undefined, newTag.typeExpression, oldTag.comment);
146282
146304
  }
146283
146305
  }
146284
146306
  // find first non-whitespace position in the leading trivia of the node
@@ -149817,7 +149839,8 @@ var ts;
149817
149839
  codefix.getImportCompletionAction = getImportCompletionAction;
149818
149840
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
149819
149841
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
149820
- return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, host, preferences);
149842
+ var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
149843
+ return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter);
149821
149844
  }
149822
149845
  function codeFixActionToCodeAction(_a) {
149823
149846
  var description = _a.description, changes = _a.changes, commands = _a.commands;
@@ -149872,12 +149895,12 @@ var ts;
149872
149895
  return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
149873
149896
  }
149874
149897
  }
149875
- function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, fromCacheOnly) {
149898
+ function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
149876
149899
  var _a = getNewImportFixes(program, importingFile,
149877
149900
  /*position*/ undefined,
149878
149901
  /*isValidTypeOnlyUseSite*/ false,
149879
149902
  /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
149880
- var result = getBestFix(fixes, importingFile, program, host, preferences);
149903
+ var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host));
149881
149904
  return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
149882
149905
  }
149883
149906
  codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
@@ -150097,23 +150120,22 @@ var ts;
150097
150120
  var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
150098
150121
  ? getFixesInfoForUMDImport(context, symbolToken)
150099
150122
  : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined;
150100
- return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, context.host, context.preferences) });
150123
+ var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
150124
+ return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
150101
150125
  }
150102
- function sortFixes(fixes, sourceFile, program, host, preferences) {
150103
- var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier;
150104
- return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, allowsImportingSpecifier); });
150126
+ function sortFixes(fixes, sourceFile, program, packageJsonImportFilter) {
150127
+ return ts.sort(fixes, function (a, b) { return ts.compareValues(a.kind, b.kind) || compareModuleSpecifiers(a, b, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier); });
150105
150128
  }
150106
- function getBestFix(fixes, sourceFile, program, host, preferences) {
150129
+ function getBestFix(fixes, sourceFile, program, packageJsonImportFilter) {
150107
150130
  if (!ts.some(fixes))
150108
150131
  return;
150109
150132
  // These will always be placed first if available, and are better than other kinds
150110
150133
  if (fixes[0].kind === 0 /* UseNamespace */ || fixes[0].kind === 2 /* AddToExisting */) {
150111
150134
  return fixes[0];
150112
150135
  }
150113
- var allowsImportingSpecifier = ts.createPackageJsonImportFilter(sourceFile, preferences, host).allowsImportingSpecifier;
150114
150136
  return fixes.reduce(function (best, fix) {
150115
150137
  // Takes true branch of conditional if `fix` is better than `best`
150116
- return compareModuleSpecifiers(fix, best, sourceFile, program, allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
150138
+ return compareModuleSpecifiers(fix, best, sourceFile, program, packageJsonImportFilter.allowsImportingSpecifier) === -1 /* LessThan */ ? fix : best;
150117
150139
  });
150118
150140
  }
150119
150141
  /** @returns `Comparison.LessThan` if `a` is better than `b`. */
@@ -152965,7 +152987,7 @@ var ts;
152965
152987
  });
152966
152988
  var name = declaration && ts.getNameOfDeclaration(declaration);
152967
152989
  return !name || changes.length === 0 ? undefined
152968
- : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), name.getText(sourceFile)], fixId, ts.Diagnostics.Infer_all_types_from_usage)];
152990
+ : [codefix.createCodeFixAction(fixId, changes, [getDiagnostic(errorCode, token), ts.getTextOfNode(name)], fixId, ts.Diagnostics.Infer_all_types_from_usage)];
152969
152991
  },
152970
152992
  fixIds: [fixId],
152971
152993
  getAllCodeActions: function (context) {
@@ -153043,7 +153065,7 @@ var ts;
153043
153065
  case ts.Diagnostics.Variable_0_implicitly_has_an_1_type.code: {
153044
153066
  var symbol = program.getTypeChecker().getSymbolAtLocation(token);
153045
153067
  if (symbol && symbol.valueDeclaration && ts.isVariableDeclaration(symbol.valueDeclaration) && markSeen(symbol.valueDeclaration)) {
153046
- annotateVariableDeclaration(changes, importAdder, sourceFile, symbol.valueDeclaration, program, host, cancellationToken);
153068
+ annotateVariableDeclaration(changes, importAdder, ts.getSourceFileOfNode(symbol.valueDeclaration), symbol.valueDeclaration, program, host, cancellationToken);
153047
153069
  importAdder.writeFixes(changes);
153048
153070
  return symbol.valueDeclaration;
153049
153071
  }
@@ -154742,35 +154764,34 @@ var ts;
154742
154764
  codefix.registerCodeFix({
154743
154765
  errorCodes: errorCodes,
154744
154766
  getCodeActions: function getCodeActionsForStrictClassInitializationErrors(context) {
154745
- var propertyDeclaration = getPropertyDeclaration(context.sourceFile, context.span.start);
154746
- if (!propertyDeclaration)
154767
+ var info = getInfo(context.sourceFile, context.span.start);
154768
+ if (!info)
154747
154769
  return;
154748
- var result = [
154749
- getActionForAddMissingUndefinedType(context, propertyDeclaration),
154750
- getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration)
154751
- ];
154752
- ts.append(result, getActionForAddMissingInitializer(context, propertyDeclaration));
154770
+ var result = [];
154771
+ ts.append(result, getActionForAddMissingUndefinedType(context, info));
154772
+ ts.append(result, getActionForAddMissingDefiniteAssignmentAssertion(context, info));
154773
+ ts.append(result, getActionForAddMissingInitializer(context, info));
154753
154774
  return result;
154754
154775
  },
154755
154776
  fixIds: [fixIdAddDefiniteAssignmentAssertions, fixIdAddUndefinedType, fixIdAddInitializer],
154756
154777
  getAllCodeActions: function (context) {
154757
154778
  return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
154758
- var propertyDeclaration = getPropertyDeclaration(diag.file, diag.start);
154759
- if (!propertyDeclaration)
154779
+ var info = getInfo(diag.file, diag.start);
154780
+ if (!info)
154760
154781
  return;
154761
154782
  switch (context.fixId) {
154762
154783
  case fixIdAddDefiniteAssignmentAssertions:
154763
- addDefiniteAssignmentAssertion(changes, diag.file, propertyDeclaration);
154784
+ addDefiniteAssignmentAssertion(changes, diag.file, info.prop);
154764
154785
  break;
154765
154786
  case fixIdAddUndefinedType:
154766
- addUndefinedType(changes, diag.file, propertyDeclaration);
154787
+ addUndefinedType(changes, diag.file, info);
154767
154788
  break;
154768
154789
  case fixIdAddInitializer:
154769
154790
  var checker = context.program.getTypeChecker();
154770
- var initializer = getInitializer(checker, propertyDeclaration);
154791
+ var initializer = getInitializer(checker, info.prop);
154771
154792
  if (!initializer)
154772
154793
  return;
154773
- addInitializer(changes, diag.file, propertyDeclaration, initializer);
154794
+ addInitializer(changes, diag.file, info.prop, initializer);
154774
154795
  break;
154775
154796
  default:
154776
154797
  ts.Debug.fail(JSON.stringify(context.fixId));
@@ -154778,35 +154799,50 @@ var ts;
154778
154799
  });
154779
154800
  },
154780
154801
  });
154781
- function getPropertyDeclaration(sourceFile, pos) {
154802
+ function getInfo(sourceFile, pos) {
154782
154803
  var token = ts.getTokenAtPosition(sourceFile, pos);
154783
- return ts.isIdentifier(token) ? ts.cast(token.parent, ts.isPropertyDeclaration) : undefined;
154804
+ if (ts.isIdentifier(token) && ts.isPropertyDeclaration(token.parent)) {
154805
+ var type = ts.getEffectiveTypeAnnotationNode(token.parent);
154806
+ if (type) {
154807
+ return { type: type, prop: token.parent, isJs: ts.isInJSFile(token.parent) };
154808
+ }
154809
+ }
154810
+ return undefined;
154784
154811
  }
154785
- function getActionForAddMissingDefiniteAssignmentAssertion(context, propertyDeclaration) {
154786
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, propertyDeclaration); });
154787
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, propertyDeclaration.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
154812
+ function getActionForAddMissingDefiniteAssignmentAssertion(context, info) {
154813
+ if (info.isJs)
154814
+ return undefined;
154815
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addDefiniteAssignmentAssertion(t, context.sourceFile, info.prop); });
154816
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_definite_assignment_assertion_to_property_0, info.prop.getText()], fixIdAddDefiniteAssignmentAssertions, ts.Diagnostics.Add_definite_assignment_assertions_to_all_uninitialized_properties);
154788
154817
  }
154789
154818
  function addDefiniteAssignmentAssertion(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
154790
154819
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, ts.factory.createToken(53 /* ExclamationToken */), propertyDeclaration.type, propertyDeclaration.initializer);
154791
154820
  changeTracker.replaceNode(propertyDeclarationSourceFile, propertyDeclaration, property);
154792
154821
  }
154793
- function getActionForAddMissingUndefinedType(context, propertyDeclaration) {
154794
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, propertyDeclaration); });
154795
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, propertyDeclaration.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
154822
+ function getActionForAddMissingUndefinedType(context, info) {
154823
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addUndefinedType(t, context.sourceFile, info); });
154824
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_undefined_type_to_property_0, info.prop.name.getText()], fixIdAddUndefinedType, ts.Diagnostics.Add_undefined_type_to_all_uninitialized_properties);
154796
154825
  }
154797
- function addUndefinedType(changeTracker, propertyDeclarationSourceFile, propertyDeclaration) {
154826
+ function addUndefinedType(changeTracker, sourceFile, info) {
154798
154827
  var undefinedTypeNode = ts.factory.createKeywordTypeNode(152 /* UndefinedKeyword */);
154799
- var type = propertyDeclaration.type; // TODO: GH#18217
154800
- var types = ts.isUnionTypeNode(type) ? type.types.concat(undefinedTypeNode) : [type, undefinedTypeNode];
154801
- changeTracker.replaceNode(propertyDeclarationSourceFile, type, ts.factory.createUnionTypeNode(types));
154828
+ var types = ts.isUnionTypeNode(info.type) ? info.type.types.concat(undefinedTypeNode) : [info.type, undefinedTypeNode];
154829
+ var unionTypeNode = ts.factory.createUnionTypeNode(types);
154830
+ if (info.isJs) {
154831
+ changeTracker.addJSDocTags(sourceFile, info.prop, [ts.factory.createJSDocTypeTag(/*tagName*/ undefined, ts.factory.createJSDocTypeExpression(unionTypeNode))]);
154832
+ }
154833
+ else {
154834
+ changeTracker.replaceNode(sourceFile, info.type, unionTypeNode);
154835
+ }
154802
154836
  }
154803
- function getActionForAddMissingInitializer(context, propertyDeclaration) {
154837
+ function getActionForAddMissingInitializer(context, info) {
154838
+ if (info.isJs)
154839
+ return undefined;
154804
154840
  var checker = context.program.getTypeChecker();
154805
- var initializer = getInitializer(checker, propertyDeclaration);
154841
+ var initializer = getInitializer(checker, info.prop);
154806
154842
  if (!initializer)
154807
154843
  return undefined;
154808
- var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, propertyDeclaration, initializer); });
154809
- return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, propertyDeclaration.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
154844
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addInitializer(t, context.sourceFile, info.prop, initializer); });
154845
+ return codefix.createCodeFixAction(fixName, changes, [ts.Diagnostics.Add_initializer_to_property_0, info.prop.name.getText()], fixIdAddInitializer, ts.Diagnostics.Add_initializers_to_all_uninitialized_properties);
154810
154846
  }
154811
154847
  function addInitializer(changeTracker, propertyDeclarationSourceFile, propertyDeclaration, initializer) {
154812
154848
  var property = ts.factory.updatePropertyDeclaration(propertyDeclaration, propertyDeclaration.decorators, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, propertyDeclaration.type, initializer);
@@ -161308,6 +161344,7 @@ var ts;
161308
161344
  hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
161309
161345
  trace: parseConfigHost.trace,
161310
161346
  resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
161347
+ getModuleResolutionCache: ts.maybeBind(host, host.getModuleResolutionCache),
161311
161348
  resolveTypeReferenceDirectives: ts.maybeBind(host, host.resolveTypeReferenceDirectives),
161312
161349
  useSourceOfProjectReferenceRedirect: ts.maybeBind(host, host.useSourceOfProjectReferenceRedirect),
161313
161350
  getParsedCommandLine: getParsedCommandLine,
@@ -165521,6 +165558,9 @@ var ts;
165521
165558
  Project.prototype.resolveModuleNames = function (moduleNames, containingFile, reusedNames, redirectedReference, _options, containingSourceFile) {
165522
165559
  return this.resolutionCache.resolveModuleNames(moduleNames, containingFile, reusedNames, redirectedReference, containingSourceFile);
165523
165560
  };
165561
+ Project.prototype.getModuleResolutionCache = function () {
165562
+ return this.resolutionCache.getModuleResolutionCache();
165563
+ };
165524
165564
  Project.prototype.getResolvedModuleWithFailedLookupLocationsFromCache = function (moduleName, containingFile, resolutionMode) {
165525
165565
  return this.resolutionCache.getResolvedModuleWithFailedLookupLocationsFromCache(moduleName, containingFile, resolutionMode);
165526
165566
  };
@@ -166783,6 +166823,7 @@ var ts;
166783
166823
  if (!program) {
166784
166824
  return ts.emptyArray;
166785
166825
  }
166826
+ var start = ts.timestamp();
166786
166827
  var dependencyNames;
166787
166828
  var rootNames;
166788
166829
  var rootFileName = ts.combinePaths(hostProject.currentDirectory, ts.inferredTypesContainingFile);
@@ -166792,14 +166833,14 @@ var ts;
166792
166833
  (_a = packageJson.dependencies) === null || _a === void 0 ? void 0 : _a.forEach(function (_, dependenyName) { return addDependency(dependenyName); });
166793
166834
  (_b = packageJson.peerDependencies) === null || _b === void 0 ? void 0 : _b.forEach(function (_, dependencyName) { return addDependency(dependencyName); });
166794
166835
  }
166836
+ var dependenciesAdded = 0;
166795
166837
  if (dependencyNames) {
166796
- var dependenciesAdded = 0;
166797
166838
  var symlinkCache = hostProject.getSymlinkCache();
166798
166839
  for (var _c = 0, _d = ts.arrayFrom(dependencyNames.keys()); _c < _d.length; _c++) {
166799
166840
  var name = _d[_c];
166800
166841
  // Avoid creating a large project that would significantly slow down time to editor interactivity
166801
166842
  if (dependencySelection === 2 /* Auto */ && dependenciesAdded > this.maxDependencies) {
166802
- hostProject.log("Auto-import provider attempted to add more than " + this.maxDependencies + " dependencies.");
166843
+ hostProject.log("AutoImportProviderProject: attempted to add more than " + this.maxDependencies + " dependencies. Aborting.");
166803
166844
  return ts.emptyArray;
166804
166845
  }
166805
166846
  // 1. Try to load from the implementation package. For many dependencies, the
@@ -166833,6 +166874,9 @@ var ts;
166833
166874
  }
166834
166875
  }
166835
166876
  }
166877
+ if (rootNames === null || rootNames === void 0 ? void 0 : rootNames.length) {
166878
+ hostProject.log("AutoImportProviderProject: found " + rootNames.length + " root files in " + dependenciesAdded + " dependencies in " + (ts.timestamp() - start) + " ms");
166879
+ }
166836
166880
  return rootNames || ts.emptyArray;
166837
166881
  function addDependency(dependency) {
166838
166882
  if (!ts.startsWith(dependency, "@types/")) {
@@ -166933,6 +166977,11 @@ var ts;
166933
166977
  return this.hostProject.getSymlinkCache();
166934
166978
  };
166935
166979
  /*@internal*/
166980
+ AutoImportProviderProject.prototype.getModuleResolutionCache = function () {
166981
+ var _a;
166982
+ return (_a = this.hostProject.getCurrentProgram()) === null || _a === void 0 ? void 0 : _a.getModuleResolutionCache();
166983
+ };
166984
+ /*@internal*/
166936
166985
  AutoImportProviderProject.maxDependencies = 10;
166937
166986
  /*@internal*/
166938
166987
  AutoImportProviderProject.compilerOptionsOverrides = {
@@ -6594,6 +6594,7 @@ declare namespace ts {
6594
6594
  externalModuleName = "external module name",
6595
6595
  /**
6596
6596
  * <JsxTagName attribute1 attribute2={0} />
6597
+ * @deprecated
6597
6598
  */
6598
6599
  jsxAttribute = "JSX attribute",
6599
6600
  /** String literal */