`vue-tsc` throws error when importing `vite-ssg/single-page`
wtho opened this issue · comments
wtho commented
When importing from vite-ssg/single-page
in a TypeScript, vue-tsc
will throw an error.
This is due to the script scripts/copy-single-page-dts.ts
, which blindly copies the type definitions in the dist root, so it can be found by tsc
at vite-ssg/single-page.d.ts
.
What causes the error is a relative import in single-page.d.ts
, which is incorrect after moving it one folder up:
single-page.ts
:
// ...
import type { ViteSSGClientOptions, ViteSSGContext } from '../types'
import { deserializeState } from '../utils/state'
import { documentReady } from '../utils/document-ready'
// ...
which compiles e. g. to single-page.d.ts
:
import { Component } from 'vue';
import { V as ViteSSGContext, a as ViteSSGClientOptions } from '../types-afd5a7d9';
export { R as RouterOptions, a as ViteSSGClientOptions, V as ViteSSGContext, b as ViteSSGOptions } from '../types-afd5a7d9';
import 'vue-router';
import '@vueuse/head';
import 'critters';
declare function ViteSSG(App: Component, fn?: (context: ViteSSGContext<false>) => Promise<void> | void, options?: ViteSSGClientOptions): (client?: boolean) => Promise<ViteSSGContext<false>>;
export { ViteSSG };
When running vue-tsc
, I get this error:
node_modules/vite-ssg/single-page.d.ts:2:64 - error TS2307: Cannot find module '../types-afd5a7d9' or its corresponding type declarations.
2 import { V as ViteSSGContext, a as ViteSSGClientOptions } from '../types-afd5a7d9';
~~~~~~~~~~~~~~~~~~~
node_modules/vite-ssg/single-page.d.ts:3:105 - error TS2307: Cannot find module '../types-afd5a7d9' or its corresponding type declarations.
3 export { R as RouterOptions, a as ViteSSGClientOptions, V as ViteSSGContext, b as ViteSSGOptions } from '../types-afd5a7d9';
~~~~~~~~~~~~~~~~~~~
Found 2 errors.
If I go in manually and fix the paths to './dist/types-afd5a7d9'
, it compiles again.
Joaquín Sánchez commented
@wtho I'll fix later
loggerhead commented
I have encountered the same problem. When will the PR be merged?