无法导入typescript类型?

问题描述 投票:0回答:1

我找不到如何从

dexie-export-import
导入类型 ExportProgress:

如果我这样做:

  import "dexie-export-import";

  function progressCallback ({totalRows, completedRows, ...restProps} : ExportProgress) {
    console.log(`Progress: ${completedRows} of ${totalRows} rows completed`);
    return true;
  }

然后我得到一个错误:

Error: Cannot find name 'ExportProgress'. 

如果我这样做:

  import type { ExportProgress } from "dexie-export-import";

然后我收到错误

Error: Module '"dexie-export-import"' has no exported member 'ExportProgress'. Did you mean to use 'import ExportProgress from "dexie-export-import"' instead? (ts)

图书馆将其导出这里通过:

export interface ExportProgress {
  totalTables: number;
  completedTables: number;
  totalRows: number | undefined;
  completedRows: number;
  done: boolean;
}

知道我错过了什么吗?我正在使用 sveltekit + vite,我尝试将

tsconfig.json
中的
{"compilerOptions": {"moduleResolution": "bundler"}}
更改为:

{"compilerOptions": {"moduleResolution": "node", …}}

没有成功

typescript dexie
1个回答
0
投票

您的答案在错误消息中:

Did you mean to use 'import ExportProgress from "dexie-export-import"' instead? (ts)

尝试

import ExportProgress from "dexie-export-import";
© www.soinside.com 2019 - 2024. All rights reserved.