@typescript-deploys/pr-build 4.9.0-pr-50903-10 → 4.9.0-pr-50976-13

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.
@@ -108,7 +108,7 @@ var ts;
108
108
  // The following is baselined as a literal template type without intervention
109
109
  /** The version of the TypeScript compiler release */
110
110
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
111
- ts.version = "".concat(ts.versionMajorMinor, ".0-insiders.20220922");
111
+ ts.version = "".concat(ts.versionMajorMinor, ".0-insiders.20220929");
112
112
  /* @internal */
113
113
  var Comparison;
114
114
  (function (Comparison) {
@@ -3214,11 +3214,13 @@ var ts;
3214
3214
  // > alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers
3215
3215
  // > MUST NOT include leading zeroes.
3216
3216
  var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
3217
+ var prereleasePartRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)$/i;
3217
3218
  // https://semver.org/#spec-item-10
3218
3219
  // > Build metadata MAY be denoted by appending a plus sign and a series of dot separated
3219
3220
  // > identifiers immediately following the patch or pre-release version. Identifiers MUST
3220
3221
  // > comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty.
3221
3222
  var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
3223
+ var buildPartRegExp = /^[a-z0-9-]+$/i;
3222
3224
  // https://semver.org/#spec-item-9
3223
3225
  // > Numeric identifiers MUST NOT include leading zeroes.
3224
3226
  var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
@@ -3238,13 +3240,15 @@ var ts;
3238
3240
  ts.Debug.assert(major >= 0, "Invalid argument: major");
3239
3241
  ts.Debug.assert(minor >= 0, "Invalid argument: minor");
3240
3242
  ts.Debug.assert(patch >= 0, "Invalid argument: patch");
3241
- ts.Debug.assert(!prerelease || prereleaseRegExp.test(prerelease), "Invalid argument: prerelease");
3242
- ts.Debug.assert(!build || buildRegExp.test(build), "Invalid argument: build");
3243
+ var prereleaseArray = prerelease ? ts.isArray(prerelease) ? prerelease : prerelease.split(".") : ts.emptyArray;
3244
+ var buildArray = build ? ts.isArray(build) ? build : build.split(".") : ts.emptyArray;
3245
+ ts.Debug.assert(ts.every(prereleaseArray, function (s) { return prereleasePartRegExp.test(s); }), "Invalid argument: prerelease");
3246
+ ts.Debug.assert(ts.every(buildArray, function (s) { return buildPartRegExp.test(s); }), "Invalid argument: build");
3243
3247
  this.major = major;
3244
3248
  this.minor = minor;
3245
3249
  this.patch = patch;
3246
- this.prerelease = prerelease ? prerelease.split(".") : ts.emptyArray;
3247
- this.build = build ? build.split(".") : ts.emptyArray;
3250
+ this.prerelease = prereleaseArray;
3251
+ this.build = buildArray;
3248
3252
  }
3249
3253
  Version.tryParse = function (text) {
3250
3254
  var result = tryParseComponents(text);
@@ -3283,6 +3287,10 @@ var ts;
3283
3287
  default: return ts.Debug.assertNever(field);
3284
3288
  }
3285
3289
  };
3290
+ Version.prototype.with = function (fields) {
3291
+ var _a = fields.major, major = _a === void 0 ? this.major : _a, _b = fields.minor, minor = _b === void 0 ? this.minor : _b, _c = fields.patch, patch = _c === void 0 ? this.patch : _c, _d = fields.prerelease, prerelease = _d === void 0 ? this.prerelease : _d, _e = fields.build, build = _e === void 0 ? this.build : _e;
3292
+ return new Version(major, minor, patch, prerelease, build);
3293
+ };
3286
3294
  Version.prototype.toString = function () {
3287
3295
  var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch);
3288
3296
  if (ts.some(this.prerelease))
@@ -3291,7 +3299,7 @@ var ts;
3291
3299
  result += "+".concat(this.build.join("."));
3292
3300
  return result;
3293
3301
  };
3294
- Version.zero = new Version(0, 0, 0);
3302
+ Version.zero = new Version(0, 0, 0, ["0"]);
3295
3303
  return Version;
3296
3304
  }());
3297
3305
  ts.Version = Version;
@@ -3374,6 +3382,10 @@ var ts;
3374
3382
  }
3375
3383
  return undefined;
3376
3384
  };
3385
+ /**
3386
+ * Tests whether a version matches the range. This is equivalent to `satisfies(version, range, { includePrerelease: true })`.
3387
+ * in `node-semver`.
3388
+ */
3377
3389
  VersionRange.prototype.test = function (version) {
3378
3390
  if (typeof version === "string")
3379
3391
  version = new Version(version);
@@ -3484,19 +3496,20 @@ var ts;
3484
3496
  break;
3485
3497
  case "<":
3486
3498
  case ">=":
3487
- comparators.push(createComparator(operator, version));
3499
+ comparators.push(isWildcard(minor) || isWildcard(patch) ? createComparator(operator, version.with({ prerelease: "0" })) :
3500
+ createComparator(operator, version));
3488
3501
  break;
3489
3502
  case "<=":
3490
3503
  case ">":
3491
- comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
3492
- isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
3504
+ comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major").with({ prerelease: "0" })) :
3505
+ isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor").with({ prerelease: "0" })) :
3493
3506
  createComparator(operator, version));
3494
3507
  break;
3495
3508
  case "=":
3496
3509
  case undefined:
3497
3510
  if (isWildcard(minor) || isWildcard(patch)) {
3498
- comparators.push(createComparator(">=", version));
3499
- comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
3511
+ comparators.push(createComparator(">=", version.with({ prerelease: "0" })));
3512
+ comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor").with({ prerelease: "0" })));
3500
3513
  }
3501
3514
  else {
3502
3515
  comparators.push(createComparator("=", version));
@@ -57606,16 +57619,32 @@ var ts;
57606
57619
  return getTypeFromTypeNode(typeNode);
57607
57620
  }
57608
57621
  }
57622
+ function isParameterOfContextSensitiveSignature(symbol) {
57623
+ var decl = symbol.valueDeclaration;
57624
+ if (!decl) {
57625
+ return false;
57626
+ }
57627
+ if (ts.isBindingElement(decl)) {
57628
+ decl = ts.walkUpBindingElementsAndPatterns(decl);
57629
+ }
57630
+ if (ts.isParameter(decl)) {
57631
+ return isContextSensitiveFunctionOrObjectLiteralMethod(decl.parent);
57632
+ }
57633
+ return false;
57634
+ }
57609
57635
  function getTypeOfVariableOrParameterOrProperty(symbol) {
57610
57636
  var links = getSymbolLinks(symbol);
57611
57637
  if (!links.type) {
57612
57638
  var type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
57613
57639
  // For a contextually typed parameter it is possible that a type has already
57614
57640
  // been assigned (in assignTypeToParameterAndFixTypeParameters), and we want
57615
- // to preserve this type.
57616
- if (!links.type) {
57641
+ // to preserve this type. In fact, we need to _prefer_ that type, but it won't
57642
+ // be assigned until contextual typing is complete, so we need to defer in
57643
+ // cases where contextual typing may take place.
57644
+ if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
57617
57645
  links.type = type;
57618
57646
  }
57647
+ return type;
57619
57648
  }
57620
57649
  return links.type;
57621
57650
  }
@@ -63342,7 +63371,18 @@ var ts;
63342
63371
  return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
63343
63372
  }
63344
63373
  errorIfWritingToReadonlyIndex(indexInfo);
63345
- return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
63374
+ // When accessing an enum object with its own type,
63375
+ // e.g. E[E.A] for enum E { A }, undefined shouldn't
63376
+ // be included in the result type
63377
+ if ((accessFlags & 1 /* AccessFlags.IncludeUndefined */) &&
63378
+ !(objectType.symbol &&
63379
+ objectType.symbol.flags & (256 /* SymbolFlags.RegularEnum */ | 128 /* SymbolFlags.ConstEnum */) &&
63380
+ (indexType.symbol &&
63381
+ indexType.flags & 1024 /* TypeFlags.EnumLiteral */ &&
63382
+ getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
63383
+ return getUnionType([indexInfo.type, undefinedType]);
63384
+ }
63385
+ return indexInfo.type;
63346
63386
  }
63347
63387
  if (indexType.flags & 131072 /* TypeFlags.Never */) {
63348
63388
  return neverType;
@@ -65035,13 +65075,8 @@ var ts;
65035
65075
  return ts.hasContextSensitiveParameters(node) || hasContextSensitiveReturnExpression(node);
65036
65076
  }
65037
65077
  function hasContextSensitiveReturnExpression(node) {
65038
- if (node.typeParameters || ts.getEffectiveReturnTypeNode(node) || !node.body) {
65039
- return false;
65040
- }
65041
- if (node.body.kind !== 238 /* SyntaxKind.Block */) {
65042
- return isContextSensitive(node.body);
65043
- }
65044
- return !!ts.forEachReturnStatement(node.body, function (statement) { return !!statement.expression && isContextSensitive(statement.expression); });
65078
+ // TODO(anhans): A block should be context-sensitive if it has a context-sensitive return value.
65079
+ return !node.typeParameters && !ts.getEffectiveReturnTypeNode(node) && !!node.body && node.body.kind !== 238 /* SyntaxKind.Block */ && isContextSensitive(node.body);
65045
65080
  }
65046
65081
  function isContextSensitiveFunctionOrObjectLiteralMethod(func) {
65047
65082
  return (ts.isFunctionExpressionOrArrowFunction(func) || ts.isObjectLiteralMethod(func)) &&
@@ -67004,7 +67039,7 @@ var ts;
67004
67039
  // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
67005
67040
  var constraint = getConstraintOfTypeParameter(source);
67006
67041
  if (constraint && hasNonCircularBaseConstraint(source)) {
67007
- while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) {
67042
+ while (constraint && someType(constraint, function (c) { return !!(c.flags & 262144 /* TypeFlags.TypeParameter */); })) {
67008
67043
  if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) {
67009
67044
  return result;
67010
67045
  }
@@ -70766,7 +70801,7 @@ var ts;
70766
70801
  }
70767
70802
  if (ts.isEntityNameExpression(node.argumentExpression)) {
70768
70803
  var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true);
70769
- if (!symbol || !isConstVariable(symbol))
70804
+ if (!symbol || !(isConstVariable(symbol) || (symbol.flags & 8 /* SymbolFlags.EnumMember */)))
70770
70805
  return undefined;
70771
70806
  var declaration = symbol.valueDeclaration;
70772
70807
  if (declaration === undefined)
@@ -70780,7 +70815,12 @@ var ts;
70780
70815
  }
70781
70816
  if (ts.hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node.argumentExpression)) {
70782
70817
  var initializer = ts.getEffectiveInitializer(declaration);
70783
- return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
70818
+ if (initializer) {
70819
+ return tryGetNameFromType(getTypeOfExpression(initializer));
70820
+ }
70821
+ if (ts.isEnumMember(declaration)) {
70822
+ return ts.getTextOfPropertyName(declaration.name);
70823
+ }
70784
70824
  }
70785
70825
  }
70786
70826
  return undefined;
@@ -118844,7 +118884,7 @@ var ts;
118844
118884
  * Determines if program structure is upto date or needs to be recreated
118845
118885
  */
118846
118886
  /* @internal */
118847
- function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
118887
+ function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
118848
118888
  // If we haven't created a program yet or have changed automatic type directives, then it is not up-to-date
118849
118889
  if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames()))
118850
118890
  return false;
@@ -118872,7 +118912,7 @@ var ts;
118872
118912
  return true;
118873
118913
  function sourceFileNotUptoDate(sourceFile) {
118874
118914
  return !sourceFileVersionUptoDate(sourceFile) ||
118875
- hasInvalidatedResolution(sourceFile.path);
118915
+ hasInvalidatedResolutions(sourceFile.path);
118876
118916
  }
118877
118917
  function sourceFileVersionUptoDate(sourceFile) {
118878
118918
  return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
@@ -119118,7 +119158,7 @@ var ts;
119118
119158
  var moduleResolutionCache;
119119
119159
  var typeReferenceDirectiveResolutionCache;
119120
119160
  var actualResolveModuleNamesWorker;
119121
- var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
119161
+ var hasInvalidatedResolutions = host.hasInvalidatedResolutions || ts.returnFalse;
119122
119162
  if (host.resolveModuleNames) {
119123
119163
  actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
119124
119164
  // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
@@ -119565,7 +119605,7 @@ var ts;
119565
119605
  for (var i = 0; i < moduleNames.length; i++) {
119566
119606
  var moduleName = moduleNames[i];
119567
119607
  // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
119568
- if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
119608
+ if (file === oldSourceFile && !hasInvalidatedResolutions(oldSourceFile.path)) {
119569
119609
  var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
119570
119610
  if (oldResolvedModule) {
119571
119611
  if (ts.isTraceEnabled(options, host)) {
@@ -119801,7 +119841,7 @@ var ts;
119801
119841
  // tentatively approve the file
119802
119842
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
119803
119843
  }
119804
- else if (hasInvalidatedResolution(oldSourceFile.path)) {
119844
+ else if (hasInvalidatedResolutions(oldSourceFile.path)) {
119805
119845
  // 'module/types' references could have changed
119806
119846
  structureIsReused = 1 /* StructureIsReused.SafeModules */;
119807
119847
  // add file to the modified list so that we will resolve it later
@@ -122545,10 +122585,16 @@ var ts;
122545
122585
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
122546
122586
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
122547
122587
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
122588
+ // We can only reuse emit signatures (i.e. .d.ts signatures) if the .d.ts file is unchanged,
122589
+ // which will eg be depedent on change in options like declarationDir and outDir options are unchanged.
122590
+ // We need to look in oldState.compilerOptions, rather than oldCompilerOptions (i.e.we need to disregard useOldState) because
122591
+ // oldCompilerOptions can be undefined if there was change in say module from None to some other option
122592
+ // which would make useOldState as false since we can now use reference maps that are needed to track what to emit, what to check etc
122593
+ // but that option change does not affect d.ts file name so emitSignatures should still be reused.
122548
122594
  var canCopyEmitSignatures = compilerOptions.composite &&
122549
122595
  (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
122550
122596
  !outFilePath &&
122551
- !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
122597
+ !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldState.compilerOptions);
122552
122598
  if (useOldState) {
122553
122599
  // Copy old state's changed files set
122554
122600
  (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
@@ -123847,7 +123893,7 @@ var ts;
123847
123893
  invalidateResolutionOfFile: invalidateResolutionOfFile,
123848
123894
  invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
123849
123895
  setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
123850
- createHasInvalidatedResolution: createHasInvalidatedResolution,
123896
+ createHasInvalidatedResolutions: createHasInvalidatedResolutions,
123851
123897
  isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
123852
123898
  updateTypeRootsWatch: updateTypeRootsWatch,
123853
123899
  closeTypeRootsWatch: closeTypeRootsWatch,
@@ -123902,17 +123948,13 @@ var ts;
123902
123948
  var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
123903
123949
  return !!value && !!value.length;
123904
123950
  }
123905
- function createHasInvalidatedResolution(forceAllFilesAsInvalidated) {
123951
+ function createHasInvalidatedResolutions(customHasInvalidatedResolutions) {
123906
123952
  // Ensure pending resolutions are applied
123907
123953
  invalidateResolutionsOfFailedLookupLocations();
123908
- if (forceAllFilesAsInvalidated) {
123909
- // Any file asked would have invalidated resolution
123910
- filesWithInvalidatedResolutions = undefined;
123911
- return ts.returnTrue;
123912
- }
123913
123954
  var collected = filesWithInvalidatedResolutions;
123914
123955
  filesWithInvalidatedResolutions = undefined;
123915
- return function (path) { return (!!collected && collected.has(path)) ||
123956
+ return function (path) { return customHasInvalidatedResolutions(path) ||
123957
+ !!(collected === null || collected === void 0 ? void 0 : collected.has(path)) ||
123916
123958
  isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
123917
123959
  }
123918
123960
  function startCachingPerDirectoryResolution() {
@@ -126292,6 +126334,10 @@ var ts;
126292
126334
  ts.maybeBind(host, host.getModuleResolutionCache) :
126293
126335
  (function () { return resolutionCache.getModuleResolutionCache(); });
126294
126336
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
126337
+ // All resolutions are invalid if user provided resolutions and didnt supply hasInvalidatedResolutions
126338
+ var customHasInvalidatedResolutions = userProvidedResolution ?
126339
+ ts.maybeBind(host, host.hasInvalidatedResolutions) || ts.returnTrue :
126340
+ ts.returnFalse;
126295
126341
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
126296
126342
  synchronizeProgram();
126297
126343
  // Update the wild card directory watch
@@ -126357,10 +126403,9 @@ var ts;
126357
126403
  resolutionCache.clear();
126358
126404
  }
126359
126405
  }
126360
- // All resolutions are invalid if user provided resolutions
126361
- var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution);
126406
+ var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions);
126362
126407
  var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
126363
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
126408
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
126364
126409
  if (hasChangedConfigFileParsingErrors) {
126365
126410
  if (reportFileChangeDetectedOnCreateProgram) {
126366
126411
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -126373,7 +126418,7 @@ var ts;
126373
126418
  if (reportFileChangeDetectedOnCreateProgram) {
126374
126419
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
126375
126420
  }
126376
- createNewProgram(hasInvalidatedResolution);
126421
+ createNewProgram(hasInvalidatedResolutions);
126377
126422
  }
126378
126423
  reportFileChangeDetectedOnCreateProgram = false;
126379
126424
  if (host.afterProgramCreate && program !== builderProgram) {
@@ -126386,7 +126431,7 @@ var ts;
126386
126431
  compilerHost.writeFile = originalWriteFile;
126387
126432
  return builderProgram;
126388
126433
  }
126389
- function createNewProgram(hasInvalidatedResolution) {
126434
+ function createNewProgram(hasInvalidatedResolutions) {
126390
126435
  // Compile the program
126391
126436
  writeLog("CreatingProgramWith::");
126392
126437
  writeLog(" roots: ".concat(JSON.stringify(rootFileNames)));
@@ -126397,7 +126442,7 @@ var ts;
126397
126442
  hasChangedCompilerOptions = false;
126398
126443
  hasChangedConfigFileParsingErrors = false;
126399
126444
  resolutionCache.startCachingPerDirectoryResolution();
126400
- compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
126445
+ compilerHost.hasInvalidatedResolutions = hasInvalidatedResolutions;
126401
126446
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
126402
126447
  var oldProgram = getCurrentProgram();
126403
126448
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
@@ -127984,8 +128029,15 @@ var ts;
127984
128029
  }
127985
128030
  if (buildInfo.program) {
127986
128031
  // If there are pending changes that are not emitted, project is out of date
128032
+ // When there are syntax errors, changeFileSet will have list of files changed (irrespective of noEmit)
128033
+ // But in case of semantic error we need special treatment.
128034
+ // Checking presence of affectedFilesPendingEmit list is fast and good way to tell if there were semantic errors and file emit was blocked
128035
+ // But if noEmit is true, affectedFilesPendingEmit will have file list even if there are no semantic errors to preserve list of files to be emitted when running with noEmit false
128036
+ // So with noEmit set to true, check on semantic diagnostics needs to be explicit as oppose to when it is false when only files pending emit is sufficient
127987
128037
  if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
127988
- (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
128038
+ (!project.options.noEmit ?
128039
+ (_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length :
128040
+ ts.some(buildInfo.program.semanticDiagnosticsPerFile, ts.isArray))) {
127989
128041
  return {
127990
128042
  type: ts.UpToDateStatusType.OutOfDateBuildInfo,
127991
128043
  buildInfoFile: buildInfoPath
@@ -139600,7 +139652,7 @@ var ts;
139600
139652
  break;
139601
139653
  case 202 /* SyntaxKind.ImportType */:
139602
139654
  // Only check for typeof import('xyz')
139603
- if (direct.isTypeOf && !direct.qualifier && isExported(direct)) {
139655
+ if (!isAvailableThroughGlobal && direct.isTypeOf && !direct.qualifier && isExported(direct)) {
139604
139656
  addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true);
139605
139657
  }
139606
139658
  directImports.push(direct);
@@ -168762,7 +168814,7 @@ var ts;
168762
168814
  var rootFileNames = host.getScriptFileNames().slice();
168763
168815
  // Get a fresh cache of the host information
168764
168816
  var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
168765
- var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
168817
+ var hasInvalidatedResolutions = host.hasInvalidatedResolutions || ts.returnFalse;
168766
168818
  var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames);
168767
168819
  var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host);
168768
168820
  var parsedCommandLines;
@@ -168793,7 +168845,7 @@ var ts;
168793
168845
  },
168794
168846
  onReleaseOldSourceFile: onReleaseOldSourceFile,
168795
168847
  onReleaseParsedCommandLine: onReleaseParsedCommandLine,
168796
- hasInvalidatedResolution: hasInvalidatedResolution,
168848
+ hasInvalidatedResolutions: hasInvalidatedResolutions,
168797
168849
  hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
168798
168850
  trace: ts.maybeBind(host, host.trace),
168799
168851
  resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
@@ -168833,7 +168885,7 @@ var ts;
168833
168885
  // as a const variable without downleveling, doesn't crash).
168834
168886
  var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
168835
168887
  // If the program is already up-to-date, we can reuse it
168836
- if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
168888
+ if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
168837
168889
  return;
168838
168890
  }
168839
168891
  // IMPORTANT - It is critical from this moment onward that we do not check
@@ -173708,7 +173760,7 @@ var ts;
173708
173760
  ts.Debug.assert(!this.isClosed(), "Called update graph worker of closed project");
173709
173761
  this.writeLog("Starting updateGraphWorker: Project: ".concat(this.getProjectName()));
173710
173762
  var start = ts.timestamp();
173711
- this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution();
173763
+ this.hasInvalidatedResolutions = this.resolutionCache.createHasInvalidatedResolutions(ts.returnFalse);
173712
173764
  this.resolutionCache.startCachingPerDirectoryResolution();
173713
173765
  this.program = this.languageService.getProgram(); // TODO: GH#18217
173714
173766
  this.dirty = false;
@@ -175699,18 +175751,20 @@ var ts;
175699
175751
  return ensureProject ? this.ensureDefaultProjectForFile(fileName) : this.tryGetDefaultProjectForFile(fileName);
175700
175752
  };
175701
175753
  /* @internal */
175702
- ProjectService.prototype.tryGetDefaultProjectForFile = function (fileName) {
175703
- var scriptInfo = this.getScriptInfoForNormalizedPath(fileName);
175754
+ ProjectService.prototype.tryGetDefaultProjectForFile = function (fileNameOrScriptInfo) {
175755
+ var scriptInfo = ts.isString(fileNameOrScriptInfo) ? this.getScriptInfoForNormalizedPath(fileNameOrScriptInfo) : fileNameOrScriptInfo;
175704
175756
  return scriptInfo && !scriptInfo.isOrphan() ? scriptInfo.getDefaultProject() : undefined;
175705
175757
  };
175706
175758
  /* @internal */
175707
- ProjectService.prototype.ensureDefaultProjectForFile = function (fileName) {
175708
- return this.tryGetDefaultProjectForFile(fileName) || this.doEnsureDefaultProjectForFile(fileName);
175759
+ ProjectService.prototype.ensureDefaultProjectForFile = function (fileNameOrScriptInfo) {
175760
+ return this.tryGetDefaultProjectForFile(fileNameOrScriptInfo) || this.doEnsureDefaultProjectForFile(fileNameOrScriptInfo);
175709
175761
  };
175710
- ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileName) {
175762
+ ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileNameOrScriptInfo) {
175711
175763
  this.ensureProjectStructuresUptoDate();
175712
- var scriptInfo = this.getScriptInfoForNormalizedPath(fileName);
175713
- return scriptInfo ? scriptInfo.getDefaultProject() : (this.logErrorForScriptInfoNotFound(fileName), server.Errors.ThrowNoProject());
175764
+ var scriptInfo = ts.isString(fileNameOrScriptInfo) ? this.getScriptInfoForNormalizedPath(fileNameOrScriptInfo) : fileNameOrScriptInfo;
175765
+ return scriptInfo ?
175766
+ scriptInfo.getDefaultProject() :
175767
+ (this.logErrorForScriptInfoNotFound(ts.isString(fileNameOrScriptInfo) ? fileNameOrScriptInfo : fileNameOrScriptInfo.fileName), server.Errors.ThrowNoProject());
175714
175768
  };
175715
175769
  ProjectService.prototype.getScriptInfoEnsuringProjectsUptoDate = function (uncheckedFileName) {
175716
175770
  this.ensureProjectStructuresUptoDate();
@@ -177882,7 +177936,7 @@ var ts;
177882
177936
  if (this.serverMode !== ts.LanguageServiceMode.Semantic || !this.eventHandler || !scriptInfo.isJavaScript() || !ts.addToSeen(this.allJsFilesForOpenFileTelemetry, scriptInfo.path)) {
177883
177937
  return;
177884
177938
  }
177885
- var project = scriptInfo.getDefaultProject();
177939
+ var project = this.ensureDefaultProjectForFile(scriptInfo);
177886
177940
  if (!project.languageServiceEnabled) {
177887
177941
  return;
177888
177942
  }
@@ -180482,6 +180536,10 @@ var ts;
180482
180536
  this.projectService.logErrorForScriptInfoNotFound(args.file);
180483
180537
  return server.Errors.ThrowNoProject();
180484
180538
  }
180539
+ else if (!getScriptInfoEnsuringProjectsUptoDate) {
180540
+ // Ensure there are containing projects are present
180541
+ this.projectService.ensureDefaultProjectForFile(scriptInfo);
180542
+ }
180485
180543
  projects = scriptInfo.containingProjects;
180486
180544
  symLinkedProjects = this.projectService.getSymlinkedProjects(scriptInfo);
180487
180545
  }
@@ -180608,13 +180666,7 @@ var ts;
180608
180666
  return this.getFileAndProjectWorker(args.file, args.projectFileName);
180609
180667
  };
180610
180668
  Session.prototype.getFileAndLanguageServiceForSyntacticOperation = function (args) {
180611
- // Since this is syntactic operation, there should always be project for the file
180612
- // throw if we dont get project
180613
- var file = server.toNormalizedPath(args.file);
180614
- var project = this.getProject(args.projectFileName) || this.projectService.ensureDefaultProjectForFile(file);
180615
- if (!project) {
180616
- return server.Errors.ThrowNoProject();
180617
- }
180669
+ var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
180618
180670
  return {
180619
180671
  file: file,
180620
180672
  languageService: project.getLanguageService(/*ensureSynchronized*/ false)
@@ -3320,6 +3320,8 @@ declare namespace ts {
3320
3320
  */
3321
3321
  resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
3322
3322
  getEnvironmentVariable?(name: string): string | undefined;
3323
+ /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
3324
+ hasInvalidatedResolutions?(filePath: Path): boolean;
3323
3325
  createHash?(data: string): string;
3324
3326
  getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
3325
3327
  }
@@ -5442,6 +5444,8 @@ declare namespace ts {
5442
5444
  resolveModuleNames?(moduleNames: string[], containingFile: string, reusedNames: string[] | undefined, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingSourceFile?: SourceFile): (ResolvedModule | undefined)[];
5443
5445
  /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
5444
5446
  resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
5447
+ /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
5448
+ hasInvalidatedResolutions?(filePath: Path): boolean;
5445
5449
  /**
5446
5450
  * Returns the module resolution cache used by a provided `resolveModuleNames` implementation so that any non-name module resolution operations (eg, package.json lookup) can reuse it
5447
5451
  */