@typescript-deploys/pr-build 4.9.0-pr-50776-2 → 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.
package/lib/tsserver.js CHANGED
@@ -109,7 +109,7 @@ var ts;
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = "".concat(ts.versionMajorMinor, ".0-insiders.20220922");
112
+ ts.version = "".concat(ts.versionMajorMinor, ".0-insiders.20220929");
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -3215,11 +3215,13 @@ var ts;
3215
3215
  // > alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty. Numeric identifiers
3216
3216
  // > MUST NOT include leading zeroes.
3217
3217
  var prereleaseRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)(?:\.(?:0|[1-9]\d*|[a-z-][a-z0-9-]*))*$/i;
3218
+ var prereleasePartRegExp = /^(?:0|[1-9]\d*|[a-z-][a-z0-9-]*)$/i;
3218
3219
  // https://semver.org/#spec-item-10
3219
3220
  // > Build metadata MAY be denoted by appending a plus sign and a series of dot separated
3220
3221
  // > identifiers immediately following the patch or pre-release version. Identifiers MUST
3221
3222
  // > comprise only ASCII alphanumerics and hyphen [0-9A-Za-z-]. Identifiers MUST NOT be empty.
3222
3223
  var buildRegExp = /^[a-z0-9-]+(?:\.[a-z0-9-]+)*$/i;
3224
+ var buildPartRegExp = /^[a-z0-9-]+$/i;
3223
3225
  // https://semver.org/#spec-item-9
3224
3226
  // > Numeric identifiers MUST NOT include leading zeroes.
3225
3227
  var numericIdentifierRegExp = /^(0|[1-9]\d*)$/;
@@ -3239,13 +3241,15 @@ var ts;
3239
3241
  ts.Debug.assert(major >= 0, "Invalid argument: major");
3240
3242
  ts.Debug.assert(minor >= 0, "Invalid argument: minor");
3241
3243
  ts.Debug.assert(patch >= 0, "Invalid argument: patch");
3242
- ts.Debug.assert(!prerelease || prereleaseRegExp.test(prerelease), "Invalid argument: prerelease");
3243
- ts.Debug.assert(!build || buildRegExp.test(build), "Invalid argument: build");
3244
+ var prereleaseArray = prerelease ? ts.isArray(prerelease) ? prerelease : prerelease.split(".") : ts.emptyArray;
3245
+ var buildArray = build ? ts.isArray(build) ? build : build.split(".") : ts.emptyArray;
3246
+ ts.Debug.assert(ts.every(prereleaseArray, function (s) { return prereleasePartRegExp.test(s); }), "Invalid argument: prerelease");
3247
+ ts.Debug.assert(ts.every(buildArray, function (s) { return buildPartRegExp.test(s); }), "Invalid argument: build");
3244
3248
  this.major = major;
3245
3249
  this.minor = minor;
3246
3250
  this.patch = patch;
3247
- this.prerelease = prerelease ? prerelease.split(".") : ts.emptyArray;
3248
- this.build = build ? build.split(".") : ts.emptyArray;
3251
+ this.prerelease = prereleaseArray;
3252
+ this.build = buildArray;
3249
3253
  }
3250
3254
  Version.tryParse = function (text) {
3251
3255
  var result = tryParseComponents(text);
@@ -3284,6 +3288,10 @@ var ts;
3284
3288
  default: return ts.Debug.assertNever(field);
3285
3289
  }
3286
3290
  };
3291
+ Version.prototype.with = function (fields) {
3292
+ 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;
3293
+ return new Version(major, minor, patch, prerelease, build);
3294
+ };
3287
3295
  Version.prototype.toString = function () {
3288
3296
  var result = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch);
3289
3297
  if (ts.some(this.prerelease))
@@ -3292,7 +3300,7 @@ var ts;
3292
3300
  result += "+".concat(this.build.join("."));
3293
3301
  return result;
3294
3302
  };
3295
- Version.zero = new Version(0, 0, 0);
3303
+ Version.zero = new Version(0, 0, 0, ["0"]);
3296
3304
  return Version;
3297
3305
  }());
3298
3306
  ts.Version = Version;
@@ -3375,6 +3383,10 @@ var ts;
3375
3383
  }
3376
3384
  return undefined;
3377
3385
  };
3386
+ /**
3387
+ * Tests whether a version matches the range. This is equivalent to `satisfies(version, range, { includePrerelease: true })`.
3388
+ * in `node-semver`.
3389
+ */
3378
3390
  VersionRange.prototype.test = function (version) {
3379
3391
  if (typeof version === "string")
3380
3392
  version = new Version(version);
@@ -3485,19 +3497,20 @@ var ts;
3485
3497
  break;
3486
3498
  case "<":
3487
3499
  case ">=":
3488
- comparators.push(createComparator(operator, version));
3500
+ comparators.push(isWildcard(minor) || isWildcard(patch) ? createComparator(operator, version.with({ prerelease: "0" })) :
3501
+ createComparator(operator, version));
3489
3502
  break;
3490
3503
  case "<=":
3491
3504
  case ">":
3492
- comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major")) :
3493
- isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor")) :
3505
+ comparators.push(isWildcard(minor) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("major").with({ prerelease: "0" })) :
3506
+ isWildcard(patch) ? createComparator(operator === "<=" ? "<" : ">=", version.increment("minor").with({ prerelease: "0" })) :
3494
3507
  createComparator(operator, version));
3495
3508
  break;
3496
3509
  case "=":
3497
3510
  case undefined:
3498
3511
  if (isWildcard(minor) || isWildcard(patch)) {
3499
- comparators.push(createComparator(">=", version));
3500
- comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor")));
3512
+ comparators.push(createComparator(">=", version.with({ prerelease: "0" })));
3513
+ comparators.push(createComparator("<", version.increment(isWildcard(minor) ? "major" : "minor").with({ prerelease: "0" })));
3501
3514
  }
3502
3515
  else {
3503
3516
  comparators.push(createComparator("=", version));
@@ -57607,16 +57620,32 @@ var ts;
57607
57620
  return getTypeFromTypeNode(typeNode);
57608
57621
  }
57609
57622
  }
57623
+ function isParameterOfContextSensitiveSignature(symbol) {
57624
+ var decl = symbol.valueDeclaration;
57625
+ if (!decl) {
57626
+ return false;
57627
+ }
57628
+ if (ts.isBindingElement(decl)) {
57629
+ decl = ts.walkUpBindingElementsAndPatterns(decl);
57630
+ }
57631
+ if (ts.isParameter(decl)) {
57632
+ return isContextSensitiveFunctionOrObjectLiteralMethod(decl.parent);
57633
+ }
57634
+ return false;
57635
+ }
57610
57636
  function getTypeOfVariableOrParameterOrProperty(symbol) {
57611
57637
  var links = getSymbolLinks(symbol);
57612
57638
  if (!links.type) {
57613
57639
  var type = getTypeOfVariableOrParameterOrPropertyWorker(symbol);
57614
57640
  // For a contextually typed parameter it is possible that a type has already
57615
57641
  // been assigned (in assignTypeToParameterAndFixTypeParameters), and we want
57616
- // to preserve this type.
57617
- if (!links.type) {
57642
+ // to preserve this type. In fact, we need to _prefer_ that type, but it won't
57643
+ // be assigned until contextual typing is complete, so we need to defer in
57644
+ // cases where contextual typing may take place.
57645
+ if (!links.type && !isParameterOfContextSensitiveSignature(symbol)) {
57618
57646
  links.type = type;
57619
57647
  }
57648
+ return type;
57620
57649
  }
57621
57650
  return links.type;
57622
57651
  }
@@ -63343,7 +63372,18 @@ var ts;
63343
63372
  return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
63344
63373
  }
63345
63374
  errorIfWritingToReadonlyIndex(indexInfo);
63346
- return accessFlags & 1 /* AccessFlags.IncludeUndefined */ ? getUnionType([indexInfo.type, undefinedType]) : indexInfo.type;
63375
+ // When accessing an enum object with its own type,
63376
+ // e.g. E[E.A] for enum E { A }, undefined shouldn't
63377
+ // be included in the result type
63378
+ if ((accessFlags & 1 /* AccessFlags.IncludeUndefined */) &&
63379
+ !(objectType.symbol &&
63380
+ objectType.symbol.flags & (256 /* SymbolFlags.RegularEnum */ | 128 /* SymbolFlags.ConstEnum */) &&
63381
+ (indexType.symbol &&
63382
+ indexType.flags & 1024 /* TypeFlags.EnumLiteral */ &&
63383
+ getParentOfSymbol(indexType.symbol) === objectType.symbol))) {
63384
+ return getUnionType([indexInfo.type, undefinedType]);
63385
+ }
63386
+ return indexInfo.type;
63347
63387
  }
63348
63388
  if (indexType.flags & 131072 /* TypeFlags.Never */) {
63349
63389
  return neverType;
@@ -67000,7 +67040,7 @@ var ts;
67000
67040
  // with another type parameter unless one extends the other. (Remember: comparability is mostly bidirectional!)
67001
67041
  var constraint = getConstraintOfTypeParameter(source);
67002
67042
  if (constraint && hasNonCircularBaseConstraint(source)) {
67003
- while (constraint && constraint.flags & 262144 /* TypeFlags.TypeParameter */) {
67043
+ while (constraint && someType(constraint, function (c) { return !!(c.flags & 262144 /* TypeFlags.TypeParameter */); })) {
67004
67044
  if (result = isRelatedTo(constraint, target, 1 /* RecursionFlags.Source */, /*reportErrors*/ false)) {
67005
67045
  return result;
67006
67046
  }
@@ -70762,7 +70802,7 @@ var ts;
70762
70802
  }
70763
70803
  if (ts.isEntityNameExpression(node.argumentExpression)) {
70764
70804
  var symbol = resolveEntityName(node.argumentExpression, 111551 /* SymbolFlags.Value */, /*ignoreErrors*/ true);
70765
- if (!symbol || !isConstVariable(symbol))
70805
+ if (!symbol || !(isConstVariable(symbol) || (symbol.flags & 8 /* SymbolFlags.EnumMember */)))
70766
70806
  return undefined;
70767
70807
  var declaration = symbol.valueDeclaration;
70768
70808
  if (declaration === undefined)
@@ -70776,7 +70816,12 @@ var ts;
70776
70816
  }
70777
70817
  if (ts.hasOnlyExpressionInitializer(declaration) && isBlockScopedNameDeclaredBeforeUse(declaration, node.argumentExpression)) {
70778
70818
  var initializer = ts.getEffectiveInitializer(declaration);
70779
- return initializer && tryGetNameFromType(getTypeOfExpression(initializer));
70819
+ if (initializer) {
70820
+ return tryGetNameFromType(getTypeOfExpression(initializer));
70821
+ }
70822
+ if (ts.isEnumMember(declaration)) {
70823
+ return ts.getTextOfPropertyName(declaration.name);
70824
+ }
70780
70825
  }
70781
70826
  }
70782
70827
  return undefined;
@@ -118840,7 +118885,7 @@ var ts;
118840
118885
  * Determines if program structure is upto date or needs to be recreated
118841
118886
  */
118842
118887
  /* @internal */
118843
- function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
118888
+ function isProgramUptoDate(program, rootFileNames, newOptions, getSourceVersion, fileExists, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences) {
118844
118889
  // If we haven't created a program yet or have changed automatic type directives, then it is not up-to-date
118845
118890
  if (!program || (hasChangedAutomaticTypeDirectiveNames === null || hasChangedAutomaticTypeDirectiveNames === void 0 ? void 0 : hasChangedAutomaticTypeDirectiveNames()))
118846
118891
  return false;
@@ -118868,7 +118913,7 @@ var ts;
118868
118913
  return true;
118869
118914
  function sourceFileNotUptoDate(sourceFile) {
118870
118915
  return !sourceFileVersionUptoDate(sourceFile) ||
118871
- hasInvalidatedResolution(sourceFile.path);
118916
+ hasInvalidatedResolutions(sourceFile.path);
118872
118917
  }
118873
118918
  function sourceFileVersionUptoDate(sourceFile) {
118874
118919
  return sourceFile.version === getSourceVersion(sourceFile.resolvedPath, sourceFile.fileName);
@@ -119114,7 +119159,7 @@ var ts;
119114
119159
  var moduleResolutionCache;
119115
119160
  var typeReferenceDirectiveResolutionCache;
119116
119161
  var actualResolveModuleNamesWorker;
119117
- var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
119162
+ var hasInvalidatedResolutions = host.hasInvalidatedResolutions || ts.returnFalse;
119118
119163
  if (host.resolveModuleNames) {
119119
119164
  actualResolveModuleNamesWorker = function (moduleNames, containingFile, containingFileName, reusedNames, redirectedReference) { return host.resolveModuleNames(ts.Debug.checkEachDefined(moduleNames), containingFileName, reusedNames, redirectedReference, options, containingFile).map(function (resolved) {
119120
119165
  // An older host may have omitted extension, in which case we should infer it from the file extension of resolvedFileName.
@@ -119561,7 +119606,7 @@ var ts;
119561
119606
  for (var i = 0; i < moduleNames.length; i++) {
119562
119607
  var moduleName = moduleNames[i];
119563
119608
  // If the source file is unchanged and doesnt have invalidated resolution, reuse the module resolutions
119564
- if (file === oldSourceFile && !hasInvalidatedResolution(oldSourceFile.path)) {
119609
+ if (file === oldSourceFile && !hasInvalidatedResolutions(oldSourceFile.path)) {
119565
119610
  var oldResolvedModule = ts.getResolvedModule(oldSourceFile, moduleName, getModeForResolutionAtIndex(oldSourceFile, i));
119566
119611
  if (oldResolvedModule) {
119567
119612
  if (ts.isTraceEnabled(options, host)) {
@@ -119797,7 +119842,7 @@ var ts;
119797
119842
  // tentatively approve the file
119798
119843
  modifiedSourceFiles.push({ oldFile: oldSourceFile, newFile: newSourceFile });
119799
119844
  }
119800
- else if (hasInvalidatedResolution(oldSourceFile.path)) {
119845
+ else if (hasInvalidatedResolutions(oldSourceFile.path)) {
119801
119846
  // 'module/types' references could have changed
119802
119847
  structureIsReused = 1 /* StructureIsReused.SafeModules */;
119803
119848
  // add file to the modified list so that we will resolve it later
@@ -122541,10 +122586,16 @@ var ts;
122541
122586
  var oldCompilerOptions = useOldState ? oldState.compilerOptions : undefined;
122542
122587
  var canCopySemanticDiagnostics = useOldState && oldState.semanticDiagnosticsPerFile && !!state.semanticDiagnosticsPerFile &&
122543
122588
  !ts.compilerOptionsAffectSemanticDiagnostics(compilerOptions, oldCompilerOptions);
122589
+ // We can only reuse emit signatures (i.e. .d.ts signatures) if the .d.ts file is unchanged,
122590
+ // which will eg be depedent on change in options like declarationDir and outDir options are unchanged.
122591
+ // We need to look in oldState.compilerOptions, rather than oldCompilerOptions (i.e.we need to disregard useOldState) because
122592
+ // oldCompilerOptions can be undefined if there was change in say module from None to some other option
122593
+ // 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
122594
+ // but that option change does not affect d.ts file name so emitSignatures should still be reused.
122544
122595
  var canCopyEmitSignatures = compilerOptions.composite &&
122545
122596
  (oldState === null || oldState === void 0 ? void 0 : oldState.emitSignatures) &&
122546
122597
  !outFilePath &&
122547
- !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldCompilerOptions);
122598
+ !ts.compilerOptionsAffectDeclarationPath(compilerOptions, oldState.compilerOptions);
122548
122599
  if (useOldState) {
122549
122600
  // Copy old state's changed files set
122550
122601
  (_a = oldState.changedFilesSet) === null || _a === void 0 ? void 0 : _a.forEach(function (value) { return state.changedFilesSet.add(value); });
@@ -123843,7 +123894,7 @@ var ts;
123843
123894
  invalidateResolutionOfFile: invalidateResolutionOfFile,
123844
123895
  invalidateResolutionsOfFailedLookupLocations: invalidateResolutionsOfFailedLookupLocations,
123845
123896
  setFilesWithInvalidatedNonRelativeUnresolvedImports: setFilesWithInvalidatedNonRelativeUnresolvedImports,
123846
- createHasInvalidatedResolution: createHasInvalidatedResolution,
123897
+ createHasInvalidatedResolutions: createHasInvalidatedResolutions,
123847
123898
  isFileWithInvalidatedNonRelativeUnresolvedImports: isFileWithInvalidatedNonRelativeUnresolvedImports,
123848
123899
  updateTypeRootsWatch: updateTypeRootsWatch,
123849
123900
  closeTypeRootsWatch: closeTypeRootsWatch,
@@ -123898,12 +123949,12 @@ var ts;
123898
123949
  var value = filesWithInvalidatedNonRelativeUnresolvedImports.get(path);
123899
123950
  return !!value && !!value.length;
123900
123951
  }
123901
- function createHasInvalidatedResolution(userProvidedHasInvalidatedResolution) {
123952
+ function createHasInvalidatedResolutions(customHasInvalidatedResolutions) {
123902
123953
  // Ensure pending resolutions are applied
123903
123954
  invalidateResolutionsOfFailedLookupLocations();
123904
123955
  var collected = filesWithInvalidatedResolutions;
123905
123956
  filesWithInvalidatedResolutions = undefined;
123906
- return function (path) { return (userProvidedHasInvalidatedResolution === null || userProvidedHasInvalidatedResolution === void 0 ? void 0 : userProvidedHasInvalidatedResolution(path)) ||
123957
+ return function (path) { return customHasInvalidatedResolutions(path) ||
123907
123958
  !!(collected === null || collected === void 0 ? void 0 : collected.has(path)) ||
123908
123959
  isFileWithInvalidatedNonRelativeUnresolvedImports(path); };
123909
123960
  }
@@ -126284,7 +126335,10 @@ var ts;
126284
126335
  ts.maybeBind(host, host.getModuleResolutionCache) :
126285
126336
  (function () { return resolutionCache.getModuleResolutionCache(); });
126286
126337
  var userProvidedResolution = !!host.resolveModuleNames || !!host.resolveTypeReferenceDirectives;
126287
- var userProvidedHasInvalidatedResolution = ts.maybeBind(host, host.hasInvalidatedResolution) || ts.returnTrue;
126338
+ // All resolutions are invalid if user provided resolutions and didnt supply hasInvalidatedResolutions
126339
+ var customHasInvalidatedResolutions = userProvidedResolution ?
126340
+ ts.maybeBind(host, host.hasInvalidatedResolutions) || ts.returnTrue :
126341
+ ts.returnFalse;
126288
126342
  builderProgram = readBuilderProgram(compilerOptions, compilerHost);
126289
126343
  synchronizeProgram();
126290
126344
  // Update the wild card directory watch
@@ -126350,10 +126404,9 @@ var ts;
126350
126404
  resolutionCache.clear();
126351
126405
  }
126352
126406
  }
126353
- // All resolutions are invalid if user provided resolutions
126354
- var hasInvalidatedResolution = resolutionCache.createHasInvalidatedResolution(userProvidedResolution ? userProvidedHasInvalidatedResolution : undefined);
126407
+ var hasInvalidatedResolutions = resolutionCache.createHasInvalidatedResolutions(customHasInvalidatedResolutions);
126355
126408
  var _a = ts.changeCompilerHostLikeToUseCache(compilerHost, toPath), originalReadFile = _a.originalReadFile, originalFileExists = _a.originalFileExists, originalDirectoryExists = _a.originalDirectoryExists, originalCreateDirectory = _a.originalCreateDirectory, originalWriteFile = _a.originalWriteFile;
126356
- if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
126409
+ if (ts.isProgramUptoDate(getCurrentProgram(), rootFileNames, compilerOptions, getSourceVersion, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
126357
126410
  if (hasChangedConfigFileParsingErrors) {
126358
126411
  if (reportFileChangeDetectedOnCreateProgram) {
126359
126412
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
@@ -126366,7 +126419,7 @@ var ts;
126366
126419
  if (reportFileChangeDetectedOnCreateProgram) {
126367
126420
  reportWatchDiagnostic(ts.Diagnostics.File_change_detected_Starting_incremental_compilation);
126368
126421
  }
126369
- createNewProgram(hasInvalidatedResolution);
126422
+ createNewProgram(hasInvalidatedResolutions);
126370
126423
  }
126371
126424
  reportFileChangeDetectedOnCreateProgram = false;
126372
126425
  if (host.afterProgramCreate && program !== builderProgram) {
@@ -126379,7 +126432,7 @@ var ts;
126379
126432
  compilerHost.writeFile = originalWriteFile;
126380
126433
  return builderProgram;
126381
126434
  }
126382
- function createNewProgram(hasInvalidatedResolution) {
126435
+ function createNewProgram(hasInvalidatedResolutions) {
126383
126436
  // Compile the program
126384
126437
  writeLog("CreatingProgramWith::");
126385
126438
  writeLog(" roots: ".concat(JSON.stringify(rootFileNames)));
@@ -126390,7 +126443,7 @@ var ts;
126390
126443
  hasChangedCompilerOptions = false;
126391
126444
  hasChangedConfigFileParsingErrors = false;
126392
126445
  resolutionCache.startCachingPerDirectoryResolution();
126393
- compilerHost.hasInvalidatedResolution = hasInvalidatedResolution;
126446
+ compilerHost.hasInvalidatedResolutions = hasInvalidatedResolutions;
126394
126447
  compilerHost.hasChangedAutomaticTypeDirectiveNames = hasChangedAutomaticTypeDirectiveNames;
126395
126448
  var oldProgram = getCurrentProgram();
126396
126449
  builderProgram = createProgram(rootFileNames, compilerOptions, compilerHost, builderProgram, configFileParsingDiagnostics, projectReferences);
@@ -127977,8 +128030,15 @@ var ts;
127977
128030
  }
127978
128031
  if (buildInfo.program) {
127979
128032
  // If there are pending changes that are not emitted, project is out of date
128033
+ // When there are syntax errors, changeFileSet will have list of files changed (irrespective of noEmit)
128034
+ // But in case of semantic error we need special treatment.
128035
+ // Checking presence of affectedFilesPendingEmit list is fast and good way to tell if there were semantic errors and file emit was blocked
128036
+ // 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
128037
+ // 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
127980
128038
  if (((_a = buildInfo.program.changeFileSet) === null || _a === void 0 ? void 0 : _a.length) ||
127981
- (!project.options.noEmit && ((_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length))) {
128039
+ (!project.options.noEmit ?
128040
+ (_b = buildInfo.program.affectedFilesPendingEmit) === null || _b === void 0 ? void 0 : _b.length :
128041
+ ts.some(buildInfo.program.semanticDiagnosticsPerFile, ts.isArray))) {
127982
128042
  return {
127983
128043
  type: ts.UpToDateStatusType.OutOfDateBuildInfo,
127984
128044
  buildInfoFile: buildInfoPath
@@ -139174,7 +139234,7 @@ var ts;
139174
139234
  break;
139175
139235
  case 202 /* SyntaxKind.ImportType */:
139176
139236
  // Only check for typeof import('xyz')
139177
- if (direct.isTypeOf && !direct.qualifier && isExported(direct)) {
139237
+ if (!isAvailableThroughGlobal && direct.isTypeOf && !direct.qualifier && isExported(direct)) {
139178
139238
  addIndirectUser(direct.getSourceFile(), /** addTransitiveDependencies */ true);
139179
139239
  }
139180
139240
  directImports.push(direct);
@@ -168336,7 +168396,7 @@ var ts;
168336
168396
  var rootFileNames = host.getScriptFileNames().slice();
168337
168397
  // Get a fresh cache of the host information
168338
168398
  var newSettings = host.getCompilationSettings() || getDefaultCompilerOptions();
168339
- var hasInvalidatedResolution = host.hasInvalidatedResolution || ts.returnFalse;
168399
+ var hasInvalidatedResolutions = host.hasInvalidatedResolutions || ts.returnFalse;
168340
168400
  var hasChangedAutomaticTypeDirectiveNames = ts.maybeBind(host, host.hasChangedAutomaticTypeDirectiveNames);
168341
168401
  var projectReferences = (_b = host.getProjectReferences) === null || _b === void 0 ? void 0 : _b.call(host);
168342
168402
  var parsedCommandLines;
@@ -168367,7 +168427,7 @@ var ts;
168367
168427
  },
168368
168428
  onReleaseOldSourceFile: onReleaseOldSourceFile,
168369
168429
  onReleaseParsedCommandLine: onReleaseParsedCommandLine,
168370
- hasInvalidatedResolution: hasInvalidatedResolution,
168430
+ hasInvalidatedResolutions: hasInvalidatedResolutions,
168371
168431
  hasChangedAutomaticTypeDirectiveNames: hasChangedAutomaticTypeDirectiveNames,
168372
168432
  trace: ts.maybeBind(host, host.trace),
168373
168433
  resolveModuleNames: ts.maybeBind(host, host.resolveModuleNames),
@@ -168407,7 +168467,7 @@ var ts;
168407
168467
  // as a const variable without downleveling, doesn't crash).
168408
168468
  var documentRegistryBucketKey = documentRegistry.getKeyForCompilationSettings(newSettings);
168409
168469
  // If the program is already up-to-date, we can reuse it
168410
- if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolution, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
168470
+ if (ts.isProgramUptoDate(program, rootFileNames, newSettings, function (_path, fileName) { return host.getScriptVersion(fileName); }, function (fileName) { return compilerHost.fileExists(fileName); }, hasInvalidatedResolutions, hasChangedAutomaticTypeDirectiveNames, getParsedCommandLine, projectReferences)) {
168411
168471
  return;
168412
168472
  }
168413
168473
  // IMPORTANT - It is critical from this moment onward that we do not check
@@ -173701,7 +173761,7 @@ var ts;
173701
173761
  ts.Debug.assert(!this.isClosed(), "Called update graph worker of closed project");
173702
173762
  this.writeLog("Starting updateGraphWorker: Project: ".concat(this.getProjectName()));
173703
173763
  var start = ts.timestamp();
173704
- this.hasInvalidatedResolution = this.resolutionCache.createHasInvalidatedResolution();
173764
+ this.hasInvalidatedResolutions = this.resolutionCache.createHasInvalidatedResolutions(ts.returnFalse);
173705
173765
  this.resolutionCache.startCachingPerDirectoryResolution();
173706
173766
  this.program = this.languageService.getProgram(); // TODO: GH#18217
173707
173767
  this.dirty = false;
@@ -175692,18 +175752,20 @@ var ts;
175692
175752
  return ensureProject ? this.ensureDefaultProjectForFile(fileName) : this.tryGetDefaultProjectForFile(fileName);
175693
175753
  };
175694
175754
  /* @internal */
175695
- ProjectService.prototype.tryGetDefaultProjectForFile = function (fileName) {
175696
- var scriptInfo = this.getScriptInfoForNormalizedPath(fileName);
175755
+ ProjectService.prototype.tryGetDefaultProjectForFile = function (fileNameOrScriptInfo) {
175756
+ var scriptInfo = ts.isString(fileNameOrScriptInfo) ? this.getScriptInfoForNormalizedPath(fileNameOrScriptInfo) : fileNameOrScriptInfo;
175697
175757
  return scriptInfo && !scriptInfo.isOrphan() ? scriptInfo.getDefaultProject() : undefined;
175698
175758
  };
175699
175759
  /* @internal */
175700
- ProjectService.prototype.ensureDefaultProjectForFile = function (fileName) {
175701
- return this.tryGetDefaultProjectForFile(fileName) || this.doEnsureDefaultProjectForFile(fileName);
175760
+ ProjectService.prototype.ensureDefaultProjectForFile = function (fileNameOrScriptInfo) {
175761
+ return this.tryGetDefaultProjectForFile(fileNameOrScriptInfo) || this.doEnsureDefaultProjectForFile(fileNameOrScriptInfo);
175702
175762
  };
175703
- ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileName) {
175763
+ ProjectService.prototype.doEnsureDefaultProjectForFile = function (fileNameOrScriptInfo) {
175704
175764
  this.ensureProjectStructuresUptoDate();
175705
- var scriptInfo = this.getScriptInfoForNormalizedPath(fileName);
175706
- return scriptInfo ? scriptInfo.getDefaultProject() : (this.logErrorForScriptInfoNotFound(fileName), server.Errors.ThrowNoProject());
175765
+ var scriptInfo = ts.isString(fileNameOrScriptInfo) ? this.getScriptInfoForNormalizedPath(fileNameOrScriptInfo) : fileNameOrScriptInfo;
175766
+ return scriptInfo ?
175767
+ scriptInfo.getDefaultProject() :
175768
+ (this.logErrorForScriptInfoNotFound(ts.isString(fileNameOrScriptInfo) ? fileNameOrScriptInfo : fileNameOrScriptInfo.fileName), server.Errors.ThrowNoProject());
175707
175769
  };
175708
175770
  ProjectService.prototype.getScriptInfoEnsuringProjectsUptoDate = function (uncheckedFileName) {
175709
175771
  this.ensureProjectStructuresUptoDate();
@@ -177875,7 +177937,7 @@ var ts;
177875
177937
  if (this.serverMode !== ts.LanguageServiceMode.Semantic || !this.eventHandler || !scriptInfo.isJavaScript() || !ts.addToSeen(this.allJsFilesForOpenFileTelemetry, scriptInfo.path)) {
177876
177938
  return;
177877
177939
  }
177878
- var project = scriptInfo.getDefaultProject();
177940
+ var project = this.ensureDefaultProjectForFile(scriptInfo);
177879
177941
  if (!project.languageServiceEnabled) {
177880
177942
  return;
177881
177943
  }
@@ -180475,6 +180537,10 @@ var ts;
180475
180537
  this.projectService.logErrorForScriptInfoNotFound(args.file);
180476
180538
  return server.Errors.ThrowNoProject();
180477
180539
  }
180540
+ else if (!getScriptInfoEnsuringProjectsUptoDate) {
180541
+ // Ensure there are containing projects are present
180542
+ this.projectService.ensureDefaultProjectForFile(scriptInfo);
180543
+ }
180478
180544
  projects = scriptInfo.containingProjects;
180479
180545
  symLinkedProjects = this.projectService.getSymlinkedProjects(scriptInfo);
180480
180546
  }
@@ -180601,13 +180667,7 @@ var ts;
180601
180667
  return this.getFileAndProjectWorker(args.file, args.projectFileName);
180602
180668
  };
180603
180669
  Session.prototype.getFileAndLanguageServiceForSyntacticOperation = function (args) {
180604
- // Since this is syntactic operation, there should always be project for the file
180605
- // throw if we dont get project
180606
- var file = server.toNormalizedPath(args.file);
180607
- var project = this.getProject(args.projectFileName) || this.projectService.ensureDefaultProjectForFile(file);
180608
- if (!project) {
180609
- return server.Errors.ThrowNoProject();
180610
- }
180670
+ var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
180611
180671
  return {
180612
180672
  file: file,
180613
180673
  languageService: project.getLanguageService(/*ensureSynchronized*/ false)
@@ -3320,7 +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
- hasInvalidatedResolution?(filePath: Path): boolean;
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;
3324
3325
  createHash?(data: string): string;
3325
3326
  getParsedCommandLine?(fileName: string): ParsedCommandLine | undefined;
3326
3327
  }
@@ -5444,7 +5445,7 @@ declare namespace ts {
5444
5445
  /** If provided, used to resolve type reference directives, otherwise typescript's default resolution */
5445
5446
  resolveTypeReferenceDirectives?(typeReferenceDirectiveNames: string[] | readonly FileReference[], containingFile: string, redirectedReference: ResolvedProjectReference | undefined, options: CompilerOptions, containingFileMode?: SourceFile["impliedNodeFormat"] | undefined): (ResolvedTypeReferenceDirective | undefined)[];
5446
5447
  /** If provided along with custom resolveModuleNames or resolveTypeReferenceDirectives, used to determine if unchanged file path needs to re-resolve modules/type reference directives */
5447
- hasInvalidatedResolution?(filePath: Path): boolean;
5448
+ hasInvalidatedResolutions?(filePath: Path): boolean;
5448
5449
  /**
5449
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
5450
5451
  */