language-tools
language-tools copied to clipboard
JSDoc style prop comments lost in dts output when using $$Props and ComponentProps for inheritance
Describe the bug
Props defined on a component's $$Props type that extend another component's props via Svelte's ComponentProps<> TypeScript utility function lose any JSDoc-style prop documentation.
Hover documentation works fine when referencing the Svelte components directly, it's only the built definition files generated through build commands that seem to lose the comments and break documentation.
Reproduction
ComponentA.svelte
<script lang="ts">
interface $$Props {
/** a doc */
a: string;
}
</script>
ComponentB.svelte
import type { ComponentProps } from 'svelte';
import ComponentA from './ComponentA.svelte';
<script lang="ts">
interface $$Props extends ComponentProps<ComponentA> {
/** b doc */
b: string;
}
</script>
Build the components, and inspect the .d.ts files, and you'll see that the /** a doc */ comment is missing from ComponentB.svelte.d.ts.
I've forked the language-tools repo and added a failing test demonstrating the issue. See the test Test4$$PropsExtends.svelte and the expected output Test4$$PropsExtends.svelte.d.ts.
I suspect this is coming from TS itself, but curious if there's a workaround. Thanks for any insights.
Expected behaviour
JSDoc Comments are preserved in .d.ts files.
System Info
System: OS: macOS 14.0 Binaries: Node: 18.17.1 - ~/.nvm/versions/node/v18.17.1/bin/node Yarn: 1.22.19 - ~/.nvm/versions/node/v18.17.1/bin/yarn npm: 10.1.0 - ~/.nvm/versions/node/v18.17.1/bin/npm pnpm: 8.6.1 - ~/.nvm/versions/node/v18.17.1/bin/pnpm Browsers: Chrome: 118.0.5993.70 Edge: 118.0.2088.46 Safari: 17.0 npmPackages: svelte: ^4.2.1 => 4.2.1
Which package is the issue about?
svelte2tsx
Additional Information, eg. Screenshots
No response