Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSDoc style prop comments lost in dts output when using $$Props and ComponentProps for inheritance #2186

Open
kitschpatrol opened this issue Oct 20, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@kitschpatrol
Copy link

kitschpatrol commented Oct 20, 2023

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

@kitschpatrol kitschpatrol added the bug Something isn't working label Oct 20, 2023
kitschpatrol added a commit to kitschpatrol/svelte-tweakpane-ui that referenced this issue Oct 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant