File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5817,6 +5817,7 @@ namespace ts {
58175817 const typeReferenceDirectives : FileReference [ ] = [ ] ;
58185818 const amdDependencies : { path : string ; name : string } [ ] = [ ] ;
58195819 let amdModuleName : string ;
5820+ let hasCheckDirective = false ;
58205821
58215822 // Keep scanning all the leading trivia in the file until we get to something that
58225823 // isn't trivia. Any single line comment will be analyzed to see if it is a
@@ -5878,13 +5879,17 @@ namespace ts {
58785879 amdDependencies . push ( amdDependency ) ;
58795880 }
58805881 }
5882+
5883+ const checkDirectiveRegEx = / ^ \/ \/ \s * @ c h e c k \s * / gim;
5884+ hasCheckDirective = hasCheckDirective || ! ! checkDirectiveRegEx . exec ( comment ) ;
58815885 }
58825886 }
58835887
58845888 sourceFile . referencedFiles = referencedFiles ;
58855889 sourceFile . typeReferenceDirectives = typeReferenceDirectives ;
58865890 sourceFile . amdDependencies = amdDependencies ;
58875891 sourceFile . moduleName = amdModuleName ;
5892+ sourceFile . hasCheckDirective = hasCheckDirective ;
58885893 }
58895894
58905895 function setExternalModuleIndicator ( sourceFile : SourceFile ) {
Original file line number Diff line number Diff line change @@ -907,7 +907,8 @@ namespace ts {
907907 // For JavaScript files, we don't want to report semantic errors.
908908 // Instead, we'll report errors for using TypeScript-only constructs from within a
909909 // 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 ) : [ ] ;
911912 const fileProcessingDiagnosticsInFile = fileProcessingDiagnostics . getDiagnostics ( sourceFile . fileName ) ;
912913 const programDiagnosticsInFile = programDiagnostics . getDiagnostics ( sourceFile . fileName ) ;
913914
Original file line number Diff line number Diff line change 22722272 /* @internal */ moduleAugmentations : LiteralExpression [ ] ;
22732273 /* @internal */ patternAmbientModules ?: PatternAmbientModule [ ] ;
22742274 /* @internal */ ambientModuleNames : string [ ] ;
2275+ /* @internal */ hasCheckDirective : boolean ;
22752276 }
22762277
22772278 export interface Bundle extends Node {
Original file line number Diff line number Diff line change @@ -473,6 +473,7 @@ namespace ts {
473473 public moduleAugmentations : LiteralExpression [ ] ;
474474 private namedDeclarations : Map < Declaration [ ] > ;
475475 public ambientModuleNames : string [ ] ;
476+ public hasCheckDirective : boolean ;
476477
477478 constructor ( kind : SyntaxKind , pos : number , end : number ) {
478479 super ( kind , pos , end ) ;
You can’t perform that action at this time.
0 commit comments