import { EmitResult, emit } from './';
import { Context } from '../contexts';
import { SourceFile } from 'typescript';

export const emitSourceFile = (node: SourceFile, context: Context): EmitResult =>
  node.statements
    .reduce<EmitResult>(({ context, emitted_string }, node) => {
      const result = emit(node, context);
      result.emitted_string = emitted_string + '\n' + result.emitted_string;
      return result;
    }, { context, emitted_string: '' });

import { EmitResult, emit } from './';
import { Context } from '../contexts';
import { SourceFile } from 'typescript';

export const emitSourceFile = (node: SourceFile, context): EmitResult =>
  node.statements
    .reduce((result, node) => {
      const emit_result = emit(node, context);
      emit_result.emitted_string = result.emitted_string + '\n' + emit_result.emitted_string;
      return emit_result;
    }, { context, emitted_string: '' });

--- 
+++ 
@@ -2,10 +2,10 @@
 import { Context } from '../contexts';
 import { SourceFile } from 'typescript';
 
-export const emitSourceFile = (node: SourceFile, context): EmitResult =>
+export const emitSourceFile = (node: SourceFile, context: Context): EmitResult =>
   node.statements
-    .reduce((result, node) => {
-      const emit_result = emit(node, context);
-      emit_result.emitted_string = result.emitted_string + '\n' + emit_result.emitted_string;
-      return emit_result;
+    .reduce<EmitResult>(({ context, emitted_string }, node) => {
+      const result = emit(node, context);
+      result.emitted_string = emitted_string + '\n' + result.emitted_string;
+      return result;
     }, { context, emitted_string: '' });
Fix issue with context not being updated
