typescriptdenooak

Problems with '--isolatedModules' flag and RouterContext


When trying to run my deno app the following error comes out and I don't understand why .. Has anyone encountered this problem?

run command: deno run --allow-all server.ts

error:

error: TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
  RouterContext,
  ~~~~~~~~~~~~~
    at file:///Users/XXXX/Documents/DenoAPP/deps.ts:4:3

deps.ts

export { Application, Router, RouterContext, Context, send } from "https://deno.land/x/oak@v10.4.0/mod.ts";
export { MongoClient } from "https://deno.land/x/mongo@v0.29.2/mod.ts";
export { hashSync, compareSync} from "https://deno.land/x/bcrypt@v0.3.0/mod.ts";
import "https://deno.land/x/dotenv@v3.2.0/load.ts";
export * from "https://deno.land/x/djwt@v2.4/mod.ts";

Solution

  • See --isolatedModules for an explanation.

    Checking with OAK RouterContext they do export type themselves.

    So go with the flow and split

    export { Application, Router, RouterContext, Context, send } from "https://deno.land/x/oak@v10.4.0/mod.ts";
    

    into

    export { Application, Router, send } from "https://deno.land/x/oak@v10.4.0/mod.ts";
    export type { RouterContext, Context } from "https://deno.land/x/oak@v10.4.0/mod.ts";