“--isolatedModules”的问题标志和 RouterContext

发布于 2025-01-13 12:42:16 字数 1322 浏览 4 评论 0原文

当尝试运行我的 deno 应用程序时,出现以下错误,我不明白为什么..有人遇到过这个问题吗?

运行命令: eno run --allow-all server.ts

错误:

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";

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";

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夜夜流光相皎洁 2025-01-20 12:42:16

您可以使用 在类型名称上type修饰符来解决您的问题。这是 TS 版本 ≥ 4.5 的惯用且推荐的方法:

export {
  Application,
  Router,
  type RouterContext,
  Context,
  send,
} from "https://deno.land/x/[email protected]/mod.ts";

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";
木森分化 2025-01-20 12:42:16

有关说明,请参阅 --isolatedModules

检查 OAK RouterContext 他们确实导出类型< /code> 他们自己。

所以顺其自然并

export { Application, Router, RouterContext, Context, send } from "https://deno.land/x/[email protected]/mod.ts";

分成

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";

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";
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文