typescript - 更新 Deno 后的 Typescript 导入问题
问题描述
我最近将 deno 从 v1.3.0 更新到 v1.4.0。在更新之前,我的代码没有任何问题,但之后我有这个错误:
error: TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
LevelName,
~~~~~~~~~
at https://deno.land/x/branch@0.0.2/deps.ts:8:3
TS1205 [ERROR]: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.
export { LogConfig, setup, prefix } from "./branch.ts";
~~~~~~~~~
at https://deno.land/x/branch@0.0.2/mod.ts:3:10
TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { WatcherConfig } from "./watcher.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/denon@2.3.3/src/config.ts:14:1
TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { RunnerConfig } from "./runner.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/denon@2.3.3/src/config.ts:15:1
TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { Args } from "./args.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/denon@2.3.3/src/config.ts:18:1
TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { Template } from "./templates.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/denon@2.3.3/src/config.ts:19:1
TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { Denon, DenonEvent } from "../denon.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/denon@2.3.3/src/daemon.ts:5:1
TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { CompleteDenonConfig } from "./config.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/denon@2.3.3/src/daemon.ts:6:1
TS1371 [ERROR]: This import is never used as a value and must use 'import type' because the 'importsNotUsedAsValues' is set to 'error'.
import { ScriptOptions } from "./scripts.ts";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
at https://deno.land/x/denon@2.3.3/src/daemon.ts:7:1
我找到了解决此问题的页面,但此错误看起来像是来自第三方库。我还使用 Denon 来运行脚本。这是我导入的包:
import { Application } from "https://deno.land/x/oak/mod.ts";
import { oakCors } from "https://deno.land/x/cors/mod.ts";
import { Router } from "https://deno.land/x/oak/mod.ts";
import { RouterContext } from "https://deno.land/x/oak/mod.ts";
import * as bcrypt from "https://deno.land/x/bcrypt/mod.ts";
import { SmtpClient } from "https://deno.land/x/smtp/mod.ts";
import { MongoClient } from "https://deno.land/x/mongo@v0.11.1/mod.ts";
这是我的denon.json:
{
"$schema": "https://deno.land/x/denon/schema.json",
"scripts": {
"start": {
"cmd": "deno run --unstable server.ts",
"allow": [
"net",
"write",
"read",
"plugin"
]
}
}
}
有没有办法来解决这个问题?还是降级 Deno 的方法?
解决方案
Deno v1.4.0 中添加了一个不稳定的功能。https://github.com/denoland/deno/pull/7413。这里有一个类似的问题https://github.com/Jozty/Fae/issues/32这将由库作者修复,或者您可以通过修复来提高 PR。临时解决方法是将 Deno 降级到 v1.3.0
推荐阅读
- javascript - 我使用这个 Javascript 代码,它可以完成这项工作,但我觉得它可能会更短
- onvif - 如何获取与 ONVIF(IP Camera) 设备相连的设备列表?
- javascript - 将 JavaScript 日期传递给 C# Web API 字符串属性
- angular - 在角度中使用材质颜色主题
- r - ggvis + layer_bars + 填充
- macos - 同时创建多个精灵音符
- javascript - 改进大对象数组的循环
- python - 使用 openpyxl 访问工作表。哪种方法更快?
- c - 为什么else条件在C的while循环中执行两次
- vba - Outlook:处理属性访问器隐藏附件错误