File tree Expand file tree Collapse file tree 4 files changed +9
-1
lines changed Expand file tree Collapse file tree 4 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -5817,6 +5817,7 @@ namespace ts {
5817
5817
const typeReferenceDirectives : FileReference [ ] = [ ] ;
5818
5818
const amdDependencies : { path : string ; name : string } [ ] = [ ] ;
5819
5819
let amdModuleName : string ;
5820
+ let hasCheckDirective = false ;
5820
5821
5821
5822
// Keep scanning all the leading trivia in the file until we get to something that
5822
5823
// isn't trivia. Any single line comment will be analyzed to see if it is a
@@ -5878,13 +5879,17 @@ namespace ts {
5878
5879
amdDependencies . push ( amdDependency ) ;
5879
5880
}
5880
5881
}
5882
+
5883
+ const checkDirectiveRegEx = / ^ \/ \/ \s * @ c h e c k \s * / gim;
5884
+ hasCheckDirective = hasCheckDirective || ! ! checkDirectiveRegEx . exec ( comment ) ;
5881
5885
}
5882
5886
}
5883
5887
5884
5888
sourceFile . referencedFiles = referencedFiles ;
5885
5889
sourceFile . typeReferenceDirectives = typeReferenceDirectives ;
5886
5890
sourceFile . amdDependencies = amdDependencies ;
5887
5891
sourceFile . moduleName = amdModuleName ;
5892
+ sourceFile . hasCheckDirective = hasCheckDirective ;
5888
5893
}
5889
5894
5890
5895
function setExternalModuleIndicator ( sourceFile : SourceFile ) {
Original file line number Diff line number Diff line change @@ -907,7 +907,8 @@ namespace ts {
907
907
// For JavaScript files, we don't want to report semantic errors.
908
908
// Instead, we'll report errors for using TypeScript-only constructs from within a
909
909
// JavaScript file when we get syntactic diagnostics for the file.
910
- const checkDiagnostics = ! options . checkJsFiles && isSourceFileJavaScript ( sourceFile ) ? [ ] : typeChecker . getDiagnostics ( sourceFile , cancellationToken ) ;
910
+ const includeCheckDiagnostics = options . checkJsFiles || sourceFile . hasCheckDirective || ! isSourceFileJavaScript ( sourceFile ) ;
911
+ const checkDiagnostics = includeCheckDiagnostics ? typeChecker . getDiagnostics ( sourceFile , cancellationToken ) : [ ] ;
911
912
const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics . getDiagnostics ( sourceFile . fileName ) ;
912
913
const programDiagnosticsInFile = programDiagnostics . getDiagnostics ( sourceFile . fileName ) ;
913
914
Original file line number Diff line number Diff line change 2272
2272
/* @internal */ moduleAugmentations : LiteralExpression [ ] ;
2273
2273
/* @internal */ patternAmbientModules ?: PatternAmbientModule [ ] ;
2274
2274
/* @internal */ ambientModuleNames : string [ ] ;
2275
+ /* @internal */ hasCheckDirective : boolean ;
2275
2276
}
2276
2277
2277
2278
export interface Bundle extends Node {
Original file line number Diff line number Diff line change @@ -473,6 +473,7 @@ namespace ts {
473
473
public moduleAugmentations : LiteralExpression [ ] ;
474
474
private namedDeclarations : Map < Declaration [ ] > ;
475
475
public ambientModuleNames : string [ ] ;
476
+ public hasCheckDirective : boolean ;
476
477
477
478
constructor ( kind : SyntaxKind , pos : number , end : number ) {
478
479
super ( kind , pos , end ) ;
You can’t perform that action at this time.
0 commit comments