@@ -25,15 +25,17 @@ namespace ts.server {
2525 return ( ( 1e9 * seconds ) + nanoseconds ) / 1000000.0 ;
2626 }
2727
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 ( ) ;
3637 }
38+ return false ;
3739 }
3840
3941 interface FileStart {
@@ -489,7 +491,7 @@ namespace ts.server {
489491 private semanticCheck ( file : NormalizedPath , project : Project ) {
490492 try {
491493 let diags : Diagnostic [ ] = [ ] ;
492- if ( ! shouldSkipSemanticCheck ( project ) ) {
494+ if ( ! shouldSkipSemanticCheck ( project , file ) ) {
493495 diags = project . getLanguageService ( ) . getSemanticDiagnostics ( file ) ;
494496 }
495497
@@ -597,7 +599,7 @@ namespace ts.server {
597599
598600 private getDiagnosticsWorker ( args : protocol . FileRequestArgs , isSemantic : boolean , selector : ( project : Project , file : string ) => Diagnostic [ ] , includeLinePosition : boolean ) {
599601 const { project, file } = this . getFileAndProject ( args ) ;
600- if ( isSemantic && shouldSkipSemanticCheck ( project ) ) {
602+ if ( isSemantic && shouldSkipSemanticCheck ( project , file ) ) {
601603 return [ ] ;
602604 }
603605 const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ;
0 commit comments