GetEmitOutput And Testfiles

I think you should be getting diagnostics only from files that will be merged into single file (e.g from emitJavascript)

                forEach(program.getSourceFiles(), sourceFile => {
                    if (!isExternalModuleOrDeclarationFile(sourceFile)) {
                        emit(sourceFile);
                    }
                });