@@ -1218,6 +1218,58 @@ namespace ts.tscWatch {
12181218 checkWatchedFiles ( host , files . map ( f => f . path ) ) ;
12191219 }
12201220 } ) ;
1221+
1222+ it ( "updates errors correctly when declaration emit is disabled in compiler options" , ( ) => {
1223+ const currentDirectory = "/user/username/projects/myproject" ;
1224+ const aFile : File = {
1225+ path : `${ currentDirectory } /a.ts` ,
1226+ content : `import test from './b';
1227+ test(4, 5);`
1228+ } ;
1229+ const bFileContent = `function test(x: number, y: number) {
1230+ return x + y / 5;
1231+ }
1232+ export default test;` ;
1233+ const bFile : File = {
1234+ path : `${ currentDirectory } /b.ts` ,
1235+ content : bFileContent
1236+ } ;
1237+ const tsconfigFile : File = {
1238+ path : `${ currentDirectory } /tsconfig.json` ,
1239+ content : JSON . stringify ( {
1240+ compilerOptions : {
1241+ module : "commonjs" ,
1242+ noEmit : true ,
1243+ strict : true ,
1244+ }
1245+ } )
1246+ } ;
1247+ const files = [ aFile , bFile , libFile , tsconfigFile ] ;
1248+ const host = createWatchedSystem ( files , { currentDirectory } ) ;
1249+ const watch = createWatchOfConfigFile ( "tsconfig.json" , host ) ;
1250+ checkOutputErrorsInitial ( host , emptyArray ) ;
1251+
1252+ changeParameterType ( "x" , "string" , [
1253+ getDiagnosticOfFileFromProgram ( watch ( ) , aFile . path , aFile . content . indexOf ( "4" ) , 1 , Diagnostics . Argument_of_type_0_is_not_assignable_to_parameter_of_type_1 , "4" , "string" )
1254+ ] ) ;
1255+ changeParameterType ( "y" , "string" , [
1256+ getDiagnosticOfFileFromProgram ( watch ( ) , aFile . path , aFile . content . indexOf ( "5" ) , 1 , Diagnostics . Argument_of_type_0_is_not_assignable_to_parameter_of_type_1 , "5" , "string" ) ,
1257+ getDiagnosticOfFileFromProgram ( watch ( ) , bFile . path , bFile . content . indexOf ( "y /" ) , 1 , Diagnostics . The_left_hand_side_of_an_arithmetic_operation_must_be_of_type_any_number_or_an_enum_type )
1258+ ] ) ;
1259+
1260+ function changeParameterType ( parameterName : string , toType : string , expectedErrors : ReadonlyArray < Diagnostic > ) {
1261+ const newContent = bFileContent . replace ( new RegExp ( `${ parameterName } \: [a-z]*` ) , `${ parameterName } : ${ toType } ` ) ;
1262+
1263+ verifyErrorsWithBFileContents ( newContent , expectedErrors ) ;
1264+ verifyErrorsWithBFileContents ( bFileContent , emptyArray ) ;
1265+ }
1266+
1267+ function verifyErrorsWithBFileContents ( content : string , expectedErrors : ReadonlyArray < Diagnostic > ) {
1268+ host . writeFile ( bFile . path , content ) ;
1269+ host . runQueuedTimeoutCallbacks ( ) ;
1270+ checkOutputErrorsIncremental ( host , expectedErrors ) ;
1271+ }
1272+ } ) ;
12211273 } ) ;
12221274
12231275 describe ( "tsc-watch emit with outFile or out setting" , ( ) => {
0 commit comments