'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/[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";
Solution 1:[1]
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";
Solution 2:[2]
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";
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Clemens Tolboom |
| Solution 2 | jsejcksn |
