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/[email protected]/mod.ts";
export { MongoClient } from "https://deno.land/x/[email protected]/mod.ts";
export { hashSync, compareSync} from "https://deno.land/x/[email protected]/mod.ts";
import "https://deno.land/x/[email protected]/load.ts";
export * from "https://deno.land/x/[email protected]/mod.ts";
CodePudding user response:
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/[email protected]/mod.ts";
into
export { Application, Router, send } from "https://deno.land/x/[email protected]/mod.ts";
export type { RouterContext, Context } from "https://deno.land/x/[email protected]/mod.ts";
CodePudding user response:
You can use the type
modifier on the type names to resolve your issue. This is the idiomatic and recommended approach for TS version ≥ 4.5
:
export {
Application,
Router,
type RouterContext,
Context,
send,
} from "https://deno.land/x/[email protected]/mod.ts";