Svelte 5 Props @typedef with restProps

2024-12-12

  /**
   * @typedef {Object} Props
   * @property {string} name
   */

  /** @type {Props & Record<string, any>} */
  let { name, ...restProps } = $props();

Most of my Svelte 5 components are typed with a @typdef JSDoc declaration. This seems to be the easiest way to allow restProps (i.e. “everything else”).

Do you have a better solution? Let me know :)