Emit dts not respecting abs path
#2182When I use emitDts
with an absolute path, and I am in a subfolder from my project it weirdly saves it to a path like this: /workspace/extractinator/workspace/extractinator/.temp
await emitDts({
svelteShimsPath: require.resolve('svelte2tsx/svelte-shims-v4.d.ts'),
declarationDir: '/workspace/extractinator/.temp',
libRoot: '/workspace/extractinator/playground',
})
I can provide a repo if this isn't just user error or expected - which I worry it is
It to save it at the given path
svelte2tsx
No response
I'm assuming this is known judging by the code in Svelte Package, is this the workaround (?) recommended? Using something like path.relative(cwd, tmp)
I think this is a bug. The problem is here https://github.com/sveltejs/language-tools/blob/3dc6ede879be9f36eda2f023c3c53c55df631e3a/packages/svelte2tsx/src/emitDts.ts#L97 https://github.com/sveltejs/language-tools/blob/3dc6ede879be9f36eda2f023c3c53c55df631e3a/packages/svelte2tsx/src/emitDts.ts#L131
When the tsconfig.json isn't at process.cwd()
, the path is joined with the directory path of the tsconfig.json
. We may need to add a path.isAbsolute
check before it.
Oh interesting, I can take a look closer and raise a PR if that's ok? @jasonlyu123