File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -749,12 +749,10 @@ namespace ts {
749749 return _jsxNamespace;
750750 }
751751
752- function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationToken, ignoreDiagnostics?: boolean ) {
752+ function getEmitResolver(sourceFile: SourceFile, cancellationToken: CancellationToken) {
753753 // Ensure we have all the type information in place for this file so that all the
754754 // emitter questions of this resolver will return the right information.
755- if (!ignoreDiagnostics) {
756- getDiagnostics(sourceFile, cancellationToken);
757- }
755+ getDiagnostics(sourceFile, cancellationToken);
758756 return emitResolver;
759757 }
760758
Original file line number Diff line number Diff line change @@ -1179,7 +1179,7 @@ namespace ts {
11791179 // This is because in the -out scenario all files need to be emitted, and therefore all
11801180 // files need to be type checked. And the way to specify that all files need to be type
11811181 // checked is to not pass the file to getEmitResolver.
1182- const emitResolver = getDiagnosticsProducingTypeChecker ( ) . getEmitResolver ( ( options . outFile || options . out ) ? undefined : sourceFile , cancellationToken , emitOnlyDtsFiles ) ;
1182+ const emitResolver = getDiagnosticsProducingTypeChecker ( ) . getEmitResolver ( ( options . outFile || options . out ) ? undefined : sourceFile , cancellationToken ) ;
11831183
11841184 performance . mark ( "beforeEmit" ) ;
11851185
Original file line number Diff line number Diff line change @@ -2892,7 +2892,7 @@ namespace ts {
28922892 // Should not be called directly. Should only be accessed through the Program instance.
28932893 /* @internal */ getDiagnostics ( sourceFile ?: SourceFile , cancellationToken ?: CancellationToken ) : Diagnostic [ ] ;
28942894 /* @internal */ getGlobalDiagnostics ( ) : Diagnostic [ ] ;
2895- /* @internal */ getEmitResolver ( sourceFile ?: SourceFile , cancellationToken ?: CancellationToken , ignoreDiagnostics ?: boolean ) : EmitResolver ;
2895+ /* @internal */ getEmitResolver ( sourceFile ?: SourceFile , cancellationToken ?: CancellationToken ) : EmitResolver ;
28962896
28972897 /* @internal */ getNodeCount ( ) : number ;
28982898 /* @internal */ getIdentifierCount ( ) : number ;
Original file line number Diff line number Diff line change @@ -1086,6 +1086,33 @@ namespace ts.tscWatch {
10861086 // This should be 0
10871087 host . checkTimeoutQueueLengthAndRun ( 0 ) ;
10881088 } ) ;
1089+
1090+ it ( "shouldnt report error about unused function incorrectly when file changes from global to module" , ( ) => {
1091+ const getFileContent = ( asModule : boolean ) => `
1092+ function one() {}
1093+ ${ asModule ? "export " : "" } function two() {
1094+ return function three() {
1095+ one();
1096+ }
1097+ }` ;
1098+ const file : FileOrFolder = {
1099+ path : "/a/b/file.ts" ,
1100+ content : getFileContent ( /*asModule*/ false )
1101+ } ;
1102+ const files = [ file , libFile ] ;
1103+ const host = createWatchedSystem ( files ) ;
1104+ const watch = createWatchOfFilesAndCompilerOptions ( [ file . path ] , host , {
1105+ noUnusedLocals : true
1106+ } ) ;
1107+ checkProgramActualFiles ( watch ( ) , files . map ( file => file . path ) ) ;
1108+ checkOutputErrors ( host , [ ] , ExpectedOutputErrorsPosition . AfterCompilationStarting ) ;
1109+
1110+ file . content = getFileContent ( /*asModule*/ true ) ;
1111+ host . reloadFS ( files ) ;
1112+ host . runQueuedTimeoutCallbacks ( ) ;
1113+ checkProgramActualFiles ( watch ( ) , files . map ( file => file . path ) ) ;
1114+ checkOutputErrors ( host , [ ] , ExpectedOutputErrorsPosition . AfterFileChangeDetected ) ;
1115+ } ) ;
10891116 } ) ;
10901117
10911118 describe ( "tsc-watch emit with outFile or out setting" , ( ) => {
You can’t perform that action at this time.
0 commit comments