Search code examples
typescriptdexie

Can't import typescript type?


I can't find how to import the type ExportProgress from dexie-export-import:

If I do:

  import "dexie-export-import";

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

then I get an error:

Error: Cannot find name 'ExportProgress'. 

If I do:

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

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

The library exports it here via:

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

Any idea what I'm missing? I'm using sveltekit + vite, and I tried to change in tsconfig.json the {"compilerOptions": {"moduleResolution": "bundler"}} into:

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

without success


Solution

  • Seems like it's an issue on their side. The interface you're trying to use is exported from that file but not from the library it seems. The index.ts file in their src folder just re-exports everything from dexie-export-import.ts and I don't see that interface exported there. Seems like they probably forgot to make it public. They need to explicitly re-export that interface from either index.ts or dexie-export-import.ts.

    I see you already filed an issue in their git repo, just ask them to re-export it, or you can do it yourself and submit a pull request :)