@@ -25,15 +25,17 @@ namespace ts.server {
25
25
return ( ( 1e9 * seconds ) + nanoseconds ) / 1000000.0 ;
26
26
}
27
27
28
- function shouldSkipSemanticCheck ( project : Project ) {
29
- if ( project . projectKind === ProjectKind . Inferred || project . projectKind === ProjectKind . External ) {
30
- return project . isJsOnlyProject ( ) ;
31
- }
32
- else {
33
- // For configured projects, require that skipLibCheck be set also
34
- const options = project . getCompilerOptions ( ) ;
35
- return options . skipLibCheck && ! options . checkJs && project . isJsOnlyProject ( ) ;
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).
33
+ if ( ( project . projectKind === ProjectKind . Inferred || project . projectKind === ProjectKind . External ) &&
34
+ project . isJsOnlyProject ( ) ) {
35
+ const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ;
36
+ return scriptInfo && ! scriptInfo . isJavaScript ( ) ;
36
37
}
38
+ return false ;
37
39
}
38
40
39
41
interface FileStart {
@@ -489,7 +491,7 @@ namespace ts.server {
489
491
private semanticCheck ( file : NormalizedPath , project : Project ) {
490
492
try {
491
493
let diags : Diagnostic [ ] = [ ] ;
492
- if ( ! shouldSkipSemanticCheck ( project ) ) {
494
+ if ( ! shouldSkipSemanticCheck ( project , file ) ) {
493
495
diags = project . getLanguageService ( ) . getSemanticDiagnostics ( file ) ;
494
496
}
495
497
@@ -597,7 +599,7 @@ namespace ts.server {
597
599
598
600
private getDiagnosticsWorker ( args : protocol . FileRequestArgs , isSemantic : boolean , selector : ( project : Project , file : string ) => Diagnostic [ ] , includeLinePosition : boolean ) {
599
601
const { project, file } = this . getFileAndProject ( args ) ;
600
- if ( isSemantic && shouldSkipSemanticCheck ( project ) ) {
602
+ if ( isSemantic && shouldSkipSemanticCheck ( project , file ) ) {
601
603
return [ ] ;
602
604
}
603
605
const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ;
0 commit comments