dts-buddy
dts-buddy copied to clipboard
Incorrectly leaves `import` in place
https://github.com/sveltejs/kit/pull/9605 includes a line in navigation.js
:
@type {(callback: (navigation: import('@sveltejs/kit').OnNavigate) => MaybePromise<(() => void) | void>) => void}
I believe this is incorrect. However, dts-buddy
is still able to generate some output:
export const onNavigate: (callback: (navigation: import('@sveltejs/kit').OnNavigate) => MaybePromise<void | (() => void)>) => void;
I think the line in navigation.js
should be updated to include import('types')
:
@type {(callback: (navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise<(() => void) | void>) => void}
If I do so then dts-buddy
then generates:
export const onNavigate: (callback: (navigation: import('@sveltejs/kit').OnNavigate) => import('types').MaybePromise<(() => void) | void>) => void;
...
type MaybePromise<T> = T | Promise<T>;
It seems correct that dts-buddy
then generates a type declaration for MaybePromise
, but incorrect that it leaves the import('types')
in place.
Is this still happening? There were no typechecking issues on the PR after upgrading to the latest dts-buddy
, does that mean this can be closed?
I expect it is still happening if you revert the commit @s3812497 added to the PR that he was calling a workaround: https://github.com/sveltejs/kit/pull/9605/commits/c68d625f9494b01ae7c1497ea0b5cbe96561e270. I'm not sure exactly why that fixed it or if we want to say that's how you have to use it rather than calling it a workaround
For some reason it couldn't resolve the 'types'
path that was aliased in the package.json file. The relative path and exported @sveltejs/kit path seemed to be recognised instead.
FYI I think this is fixed in the latest dts-buddy
, though I haven't had a chance to check just yet
https://github.com/sveltejs/kit/pull/11013