We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When using svelte2tsx's emitDts feature, typically, a component's props' JSDoc comments are included in the emitted .d.ts file, e.g.
emitDts
.d.ts
declare const __propDef: { props: { /** * Text content to appear in the button. */ text?: string | undefined;
However, if the component contains $$props, these prop docs disappear.
$$props
I believe this is because of the __sveltets_1_with_any shim, which is rendered by the props function, if canHaveAnyProp. Because the prop types are shimmed, we lose the documentation.
__sveltets_1_with_any
props
canHaveAnyProp
Install the SvelteKit template project (using TS syntax), install dependencies, and svelte2tsx.
svelte2tsx
npm create svelte@latest my-app npm i npm i svelte2tsx
Create a src/lib/MyComponent.svelte component with a JSDoc-ed prop.
src/lib/MyComponent.svelte
<script lang="ts"> /** * Foo docs */ export let foo = 'bar'; </script>
Run svelte2tsx's emitDts function with the following script.
import svelte2tsx from 'svelte2tsx'; import { createRequire } from 'module'; const svelteShimsPath = createRequire(import.meta.url).resolve('svelte2tsx/svelte-shims.d.ts'); svelte2tsx.emitDts({ svelteShimsPath, declarationDir: './dist' })
Inspect dist/src/lib/MyComponent.svelte.d.ts, note the presence of the prop's JSDoc.
dist/src/lib/MyComponent.svelte.d.ts
Add $$props to MyComponent.svelte.
MyComponent.svelte
<script lang="ts"> /** * Foo docs */ export let foo = 'bar'; const a = $$props.a; </script>
Re-run the above script, inspect dist/src/lib/MyComponent.svelte.d.ts again. The prop's JSDoc has disappeared.
The type file outputted by emitDts should contain prop JSDoc comments regardless of whether $$props is present in the component or not.
No response
The text was updated successfully, but these errors were encountered:
Probably the same cause as #1377
Sorry, something went wrong.
Do you think this is an easy fix? I'm not too familiar with svelte2tsx but it seems like it won't be easy to handle docs when shimming.
I'm considering removing $$props from my components to get around this.
No branches or pull requests
Describe the bug
When using svelte2tsx's
emitDts
feature, typically, a component's props' JSDoc comments are included in the emitted.d.ts
file, e.g.However, if the component contains
$$props
, these prop docs disappear.I believe this is because of the
__sveltets_1_with_any
shim, which is rendered by theprops
function, ifcanHaveAnyProp
. Because the prop types are shimmed, we lose the documentation.Reproduction
Install the SvelteKit template project (using TS syntax), install dependencies, and
svelte2tsx
.Create a
src/lib/MyComponent.svelte
component with a JSDoc-ed prop.Run
svelte2tsx
'semitDts
function with the following script.Inspect
dist/src/lib/MyComponent.svelte.d.ts
, note the presence of the prop's JSDoc.Add
$$props
toMyComponent.svelte
.Re-run the above script, inspect
dist/src/lib/MyComponent.svelte.d.ts
again. The prop's JSDoc has disappeared.Expected behaviour
The type file outputted by
emitDts
should contain prop JSDoc comments regardless of whether$$props
is present in the component or not.System Info
Which package is the issue about?
svelte2tsx
Additional Information, eg. Screenshots
No response
The text was updated successfully, but these errors were encountered: