mirror of https://github.com/sveltejs/svelte
fix: use typedef for JSDoc props and maintain comments (#13698)
* fix: use typedef for JSDoc props and maintain comments * chore: add comments * chore: add extra spaces and delete commented linepull/13702/head
parent
663a3ca550
commit
6ad017ffc5
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
'svelte': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fix: use typedef for JSDoc props and maintain comments
|
@ -0,0 +1,28 @@
|
|||||||
|
<script>
|
||||||
|
/**
|
||||||
|
* My wonderful comment
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
export let comment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* My wonderful other comment
|
||||||
|
* @type {number}
|
||||||
|
*/
|
||||||
|
export let another_comment;
|
||||||
|
|
||||||
|
// one line comment
|
||||||
|
export let one_line;
|
||||||
|
|
||||||
|
export let no_comment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
export let type_no_comment;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is optional
|
||||||
|
*/
|
||||||
|
export let optional = {stuff: true};
|
||||||
|
</script>
|
@ -0,0 +1,31 @@
|
|||||||
|
<script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} Props
|
||||||
|
* @property {string} comment - My wonderful comment
|
||||||
|
* @property {number} another_comment - My wonderful other comment
|
||||||
|
* @property {any} one_line - one line comment
|
||||||
|
* @property {any} no_comment
|
||||||
|
* @property {boolean} type_no_comment
|
||||||
|
* @property {any} [optional] - This is optional
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Props} */
|
||||||
|
let {
|
||||||
|
comment,
|
||||||
|
another_comment,
|
||||||
|
one_line,
|
||||||
|
no_comment,
|
||||||
|
type_no_comment,
|
||||||
|
optional = {stuff: true}
|
||||||
|
} = $props();
|
||||||
|
</script>
|
@ -1,5 +1,10 @@
|
|||||||
<script>
|
<script>
|
||||||
/** @type {{foo: any, [key: string]: any}} */
|
/**
|
||||||
|
* @typedef {Object} Props
|
||||||
|
* @property {any} foo
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** @type {Props & { [key: string]: any }} */
|
||||||
let { foo, ...rest } = $props();
|
let { foo, ...rest } = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in new issue