@@ -25,11 +25,20 @@ namespace ts.server {
25
25
return ( ( 1e9 * seconds ) + nanoseconds ) / 1000000.0 ;
26
26
}
27
27
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
+
33
42
if ( ( project . projectKind === ProjectKind . Inferred || project . projectKind === ProjectKind . External ) &&
34
43
project . isJsOnlyProject ( ) ) {
35
44
const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ;
@@ -491,7 +500,7 @@ namespace ts.server {
491
500
private semanticCheck ( file : NormalizedPath , project : Project ) {
492
501
try {
493
502
let diags : Diagnostic [ ] = [ ] ;
494
- if ( ! shouldSkipSemanticCheck ( project , file ) ) {
503
+ if ( ! isDeclarationFileInJSOnlyNonConfiguredProject ( project , file ) ) {
495
504
diags = project . getLanguageService ( ) . getSemanticDiagnostics ( file ) ;
496
505
}
497
506
@@ -599,7 +608,7 @@ namespace ts.server {
599
608
600
609
private getDiagnosticsWorker ( args : protocol . FileRequestArgs , isSemantic : boolean , selector : ( project : Project , file : string ) => Diagnostic [ ] , includeLinePosition : boolean ) {
601
610
const { project, file } = this . getFileAndProject ( args ) ;
602
- if ( isSemantic && shouldSkipSemanticCheck ( project , file ) ) {
611
+ if ( isSemantic && isDeclarationFileInJSOnlyNonConfiguredProject ( project , file ) ) {
603
612
return [ ] ;
604
613
}
605
614
const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ;
0 commit comments