Search code examples
typescriptgeneratorredux-saga

TypeScript isolatedModules true export generator function


I have a index.ts file that exports a generator function

export function* myFunction() { [...] }

It works fine with --isolatedModules = false but fails to compile with --isolatedModules = true

Error message during compilation:

All files must be modules when the '--isolatedModules' flag is provided.  TS1208

Solution

  • All files must be modules when the '--isolatedModules' flag is provided. TS1208

    This error happens when there is no import or export statement in a file (these make a file a module).

    The example you provided will not result in this error. However where that error is occurring, just add an export or import.