【问题标题】:Type 'string' is not assignable to type '"UnexpectedEof"'类型 'string' 不可分配给类型 '"UnexpectedEof"'
【发布时间】:2021-08-15 12:36:05
【问题描述】:

编译我的 deno 应用时出现此错误:

$ deno compile --allow-all --unstable --output ./app ./index.ts
Check file:///home/ubuntu/www/iptvfish/iptvfish-api/index.ts
error: TS2416 [ERROR]: Property 'name' in type 'PartialReadError' is not assignable to the same property in base type 'UnexpectedEof'.
  Type 'string' is not assignable to type '"UnexpectedEof"'.
  name = "PartialReadError";
  ~~~~
    at https://deno.land/std@0.74.0/io/bufio.ts:27:3
TS2416 [ERROR]: Property 'name' in type 'PartialReadError' is not assignable to the same property in base type 'UnexpectedEof'.
  Type 'string' is not assignable to type '"UnexpectedEof"'.
  name = "PartialReadError";
  ~~~~
    at https://deno.land/std@0.83.0/io/bufio.ts:27:3

Found 2 errors.
$ deno -V
deno 1.13.0

代码在我升级 deno 之前工作

【问题讨论】:

  • 你是直接导入std/io/bufio 还是被另一个依赖导入? std 库与 Deno 一起进行版本控制,并且每个新版本的 std 库都保证可以与该版本的 Deno 一起使用。 (它不一定向后兼容。)您可以尝试将该依赖项更新为兼容版本:https://deno.land/std@0.104.0/io/bufio.ts 如果您控制导入,或者您可以使用import map 将旧版本说明符映射到当前版本。跨度>
  • 必须是橡木或 denodb 使用它。我没有导入它。
  • 我不得不对一些依赖于Deno命名空间属性的版本特定语义的子依赖项使用导入映射方法,它为我解决了类似的问题。如果这最终对您有用,或者您需要更多详细信息,我将创建一个正确的答案。

标签: typescript deno


【解决方案1】:

原来它是 mysql 驱动程序和 deno 1.13.0 的一个错误(已修复,但 denodb 尚未发布他们的补丁)。

暂时你可以这样做:

// import { Database, SQLite3Connector } from 'https://deno.land/x/denodb/mod.ts';
import { Database, SQLite3Connector } from 'https://raw.githubusercontent.com/stillalivx/denodb/master/mod.ts';

【讨论】:

  • 我建议在原始 githubuser 内容 URL 中使用特定的提交 ID,以避免从 master 分支中提取破坏性更改,但是直接从 github 中提取是解决此问题的好方法!
猜你喜欢
  • 2021-09-26
  • 2019-11-15
  • 1970-01-01
  • 1970-01-01
  • 2019-05-12
  • 2021-04-28
  • 2020-07-05
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多