Svelte 5 Props @typedef with restProps


  /**
   * @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 :)

what's this?

This is an implementation of the Open Heart Protocol.
Feel free to send a reaction for this page. โ˜บ๏ธ