Skip to content

Commit 420908e

Browse files
committed
Change function name and clarify comment
1 parent 35024b4 commit 420908e

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

src/server/session.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,20 @@ namespace ts.server {
2525
return ((1e9 * seconds) + nanoseconds) / 1000000.0;
2626
}
2727

28-
function shouldSkipSemanticCheck(project: Project, file: NormalizedPath) {
29-
// For inferred (e.g. miscellaneous context in VS) and external projects (e.g. VS .csproj project) with only JS files
30-
// semantic errors in .d.ts files (e.g. ones added by automatic type acquisition) are not interesting.
31-
// We want to avoid the cost of querying for these errors all together, even if 'skipLibCheck' is not set.
32-
// We still want to check .js files (e.g. '// @ts-check' or '--checkJs' is set).
28+
function isDeclarationFileInJSOnlyNonConfiguredProject(project: Project, file: NormalizedPath) {
29+
// Checking for semantic diagnostics is an expensive process. We want to avoid it if we
30+
// know for sure it is not needed.
31+
// For instance, .d.ts files injected by ATA automatically do not produce any relevant
32+
// errors to a JS- only project.
33+
//
34+
// Note that configured projects can set skipLibCheck (on by default in jsconfig.json) to
35+
// disable checking for declaration files. We only need to verify for inferred projects (e.g.
36+
// miscellaneous context in VS) and external projects(e.g.VS.csproj project) with only JS
37+
// files.
38+
//
39+
// We still want to check .js files in a JS-only inferred or external project (e.g. if the
40+
// file has '// @ts-check').
41+
3342
if ((project.projectKind === ProjectKind.Inferred || project.projectKind === ProjectKind.External) &&
3443
project.isJsOnlyProject()) {
3544
const scriptInfo = project.getScriptInfoForNormalizedPath(file);
@@ -491,7 +500,7 @@ namespace ts.server {
491500
private semanticCheck(file: NormalizedPath, project: Project) {
492501
try {
493502
let diags: Diagnostic[] = [];
494-
if (!shouldSkipSemanticCheck(project, file)) {
503+
if (!isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) {
495504
diags = project.getLanguageService().getSemanticDiagnostics(file);
496505
}
497506

@@ -599,7 +608,7 @@ namespace ts.server {
599608

600609
private getDiagnosticsWorker(args: protocol.FileRequestArgs, isSemantic: boolean, selector: (project: Project, file: string) => Diagnostic[], includeLinePosition: boolean) {
601610
const { project, file } = this.getFileAndProject(args);
602-
if (isSemantic && shouldSkipSemanticCheck(project, file)) {
611+
if (isSemantic && isDeclarationFileInJSOnlyNonConfiguredProject(project, file)) {
603612
return [];
604613
}
605614
const scriptInfo = project.getScriptInfoForNormalizedPath(file);

0 commit comments

Comments
 (0)