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,
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220115";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220119";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -44486,7 +44486,7 @@ var ts;
44486
44486
  maybeBindExpressionFlowIfCall(node.expression);
44487
44487
  }
44488
44488
  function maybeBindExpressionFlowIfCall(node) {
44489
- // A top level or LHS of comma expression call expression with a dotted function name and at least one argument
44489
+ // A top level or comma expression call expression with a dotted function name and at least one argument
44490
44490
  // is potentially an assertion and is therefore included in the control flow.
44491
44491
  if (node.kind === 207 /* CallExpression */) {
44492
44492
  var call = node;
@@ -44654,22 +44654,27 @@ var ts;
44654
44654
  }
44655
44655
  return state;
44656
44656
  }
44657
- function onLeft(left, state, _node) {
44657
+ function onLeft(left, state, node) {
44658
44658
  if (!state.skip) {
44659
- return maybeBind(left);
44659
+ var maybeBound = maybeBind(left);
44660
+ if (node.operatorToken.kind === 27 /* CommaToken */) {
44661
+ maybeBindExpressionFlowIfCall(left);
44662
+ }
44663
+ return maybeBound;
44660
44664
  }
44661
44665
  }
44662
- function onOperator(operatorToken, state, node) {
44666
+ function onOperator(operatorToken, state, _node) {
44663
44667
  if (!state.skip) {
44664
- if (operatorToken.kind === 27 /* CommaToken */) {
44665
- maybeBindExpressionFlowIfCall(node.left);
44666
- }
44667
44668
  bind(operatorToken);
44668
44669
  }
44669
44670
  }
44670
- function onRight(right, state, _node) {
44671
+ function onRight(right, state, node) {
44671
44672
  if (!state.skip) {
44672
- return maybeBind(right);
44673
+ var maybeBound = maybeBind(right);
44674
+ if (node.operatorToken.kind === 27 /* CommaToken */) {
44675
+ maybeBindExpressionFlowIfCall(right);
44676
+ }
44677
+ return maybeBound;
44673
44678
  }
44674
44679
  }
44675
44680
  function onExit(node, state) {
@@ -50946,6 +50951,7 @@ var ts;
50946
50951
  getCommonSourceDirectory: !!host.getCommonSourceDirectory ? function () { return host.getCommonSourceDirectory(); } : function () { return ""; },
50947
50952
  getCurrentDirectory: function () { return host.getCurrentDirectory(); },
50948
50953
  getSymlinkCache: ts.maybeBind(host, host.getSymlinkCache),
50954
+ getPackageJsonInfoCache: function () { var _a; return (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host); },
50949
50955
  useCaseSensitiveFileNames: ts.maybeBind(host, host.useCaseSensitiveFileNames),
50950
50956
  redirectTargetsMap: host.redirectTargetsMap,
50951
50957
  getProjectReferenceRedirect: function (fileName) { return host.getProjectReferenceRedirect(fileName); },
@@ -95518,10 +95524,19 @@ var ts;
95518
95524
  var _a;
95519
95525
  var nonWhitespaceChildren = ts.getSemanticJsxChildren(children);
95520
95526
  var isStaticChildren = ts.length(nonWhitespaceChildren) > 1 || !!((_a = nonWhitespaceChildren[0]) === null || _a === void 0 ? void 0 : _a.dotDotDotToken);
95521
- var args = [tagName, objectProperties, !keyAttr ? factory.createVoidZero() : transformJsxAttributeInitializer(keyAttr.initializer)];
95527
+ var args = [tagName, objectProperties];
95528
+ // function jsx(type, config, maybeKey) {}
95529
+ // "maybeKey" is optional. It is acceptable to use "_jsx" without a third argument
95530
+ if (keyAttr) {
95531
+ args.push(transformJsxAttributeInitializer(keyAttr.initializer));
95532
+ }
95522
95533
  if (compilerOptions.jsx === 5 /* ReactJSXDev */) {
95523
95534
  var originalFile = ts.getOriginalNode(currentSourceFile);
95524
95535
  if (originalFile && ts.isSourceFile(originalFile)) {
95536
+ // "maybeKey" has to be replaced with "void 0" to not break the jsxDEV signature
95537
+ if (keyAttr === undefined) {
95538
+ args.push(factory.createVoidZero());
95539
+ }
95525
95540
  // isStaticChildren development flag
95526
95541
  args.push(isStaticChildren ? factory.createTrue() : factory.createFalse());
95527
95542
  // __source development flag
@@ -119386,11 +119401,12 @@ var ts;
119386
119401
  };
119387
119402
  }
119388
119403
  function isFormatRequiringExtensions(compilerOptions, importingSourceFileName, host) {
119404
+ var _a;
119389
119405
  if (ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.Node12
119390
119406
  && ts.getEmitModuleResolutionKind(compilerOptions) !== ts.ModuleResolutionKind.NodeNext) {
119391
119407
  return false;
119392
119408
  }
119393
- return ts.getImpliedNodeFormatForFile(importingSourceFileName, /*packageJsonInfoCache*/ undefined, getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
119409
+ return ts.getImpliedNodeFormatForFile(importingSourceFileName, (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host), getModuleResolutionHost(host), compilerOptions) !== ts.ModuleKind.CommonJS;
119394
119410
  }
119395
119411
  function getModuleResolutionHost(host) {
119396
119412
  var _a;
@@ -119950,11 +119966,13 @@ var ts;
119950
119966
  // For classic resolution, only allow importing from node_modules/@types, not other node_modules
119951
119967
  return ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Classic && packageName === nodeModulesDirectoryName ? undefined : packageName;
119952
119968
  function tryDirectoryWithPackageJson(packageRootIndex) {
119969
+ var _a, _b;
119953
119970
  var packageRootPath = path.substring(0, packageRootIndex);
119954
119971
  var packageJsonPath = ts.combinePaths(packageRootPath, "package.json");
119955
119972
  var moduleFileToTry = path;
119956
- if (host.fileExists(packageJsonPath)) {
119957
- var packageJsonContent = JSON.parse(host.readFile(packageJsonPath));
119973
+ var cachedPackageJson = (_b = (_a = host.getPackageJsonInfoCache) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getPackageJsonInfo(packageJsonPath);
119974
+ if (typeof cachedPackageJson === "object" || cachedPackageJson === undefined && host.fileExists(packageJsonPath)) {
119975
+ var packageJsonContent = (cachedPackageJson === null || cachedPackageJson === void 0 ? void 0 : cachedPackageJson.packageJsonContent) || JSON.parse(host.readFile(packageJsonPath));
119958
119976
  if (ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.Node12 || ts.getEmitModuleResolutionKind(options) === ts.ModuleResolutionKind.NodeNext) {
119959
119977
  // `conditions` *could* be made to go against `importingSourceFile.impliedNodeFormat` if something wanted to generate
119960
119978
  // an ImportEqualsDeclaration in an ESM-implied file or an ImportCall in a CJS-implied file. But since this function is
@@ -120793,6 +120811,7 @@ var ts;
120793
120811
  var sharedExtendedConfigFileWatchers; // Map of file watchers for extended files, shared between different referenced projects
120794
120812
  var extendedConfigCache = host.extendedConfigCache; // Cache for extended config evaluation
120795
120813
  var changesAffectResolution = false; // Flag for indicating non-config changes affect module resolution
120814
+ var reportFileChangeDetectedOnCreateProgram = false; // True if synchronizeProgram should report "File change detected..." when a new program is created
120796
120815
  var sourceFilesCache = new ts.Map(); // Cache that stores the source file and version info
120797
120816
  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
120798
120817
  var hasChangedCompilerOptions = false; // True if the compiler options have changed between compilations
@@ -120955,14 +120974,21 @@ var ts;
120955
120974
  var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution || changesAffectResolution);
120956
120975
  if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
120957
120976
  if (hasChangedConfigFileParsingErrors) {
120977
+ if (reportFileChangeDetectedOnCreateProgram) {
120978
+ reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
120979
+ }
120958
120980
  builderProgram = createProgram(/*rootNames*/ undefined, /*options*/ undefined, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
120959
120981
  hasChangedConfigFileParsingErrors = false;
120960
120982
  }
120961
120983
  }
120962
120984
  else {
120985
+ if (reportFileChangeDetectedOnCreateProgram) {
120986
+ reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
120987
+ }
120963
120988
  createNewProgram(hasInvalidatedResolution);
120964
120989
  }
120965
120990
  changesAffectResolution = false; // reset for next sync
120991
+ reportFileChangeDetectedOnCreateProgram = false;
120966
120992
  if (host.afterProgramCreate && program !== builderProgram) {
120967
120993
  host.afterProgramCreate(builderProgram);
120968
120994
  }
@@ -121164,7 +121190,7 @@ var ts;
121164
121190
  }
121165
121191
  function updateProgramWithWatchStatus() {
121166
121192
  timerToUpdateProgram = undefined;
121167
- reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
121193
+ reportFileChangeDetectedOnCreateProgram = true;
121168
121194
  updateProgram();
121169
121195
  }
121170
121196
  function updateProgram() {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.6.0-dev.20220115",
5
+ "version": "4.6.0-dev.20220119",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [