Skip to content

Migrate script removes JSDoc comments when there are default values #15530

Closed
@rgieseke

Description

@rgieseke

Describe the bug

When running npx sv migrate svelte-5 JSDoc comments of the following form in a Svelte 4 app

<script>
	/** @type {number} [default_value=1] */
	export let default_value = 1;

	/** @type {number} [comment_default_value=1] - This has a comment and an optional value. */
	export let comment_default_value = 1;
</script>

get converted to the following, the comments and default value are not included after the conversion.

<script>
	/**
	 * @typedef {Object} Props
	 * @property {number} [default_value]
	 * @property {number} [comment_default_value]
	 */

	/** @type {Props} */
	let { default_value = 1, comment_default_value = 1 } = $props();
</script>

From running npx vitest packages/svelte/tests/migrate -t="jsdoc-with-comments" and looking around in the migrate script it seems that cleaned_comment is empty here which I think it shouldn't?

let cleaned_comment = cleaned_comment_arr

Happy to help fix this but would need some further pointers how.

I tried updating Layer Cake components to Svelte 5 syntax.

Reproduction

I have failing test cases here: rgieseke@634ccc6

System Info

Node: 22.13.1 - ~/.local/bin/node
    npm: 10.9.2 - ~/.local/bin/npm
    pnpm: 9.4.0 - ~/.local/bin/pnpm
npmPackages:
    svelte: workspace:^ => 5.23.1

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions