Skip to content

How to make inline snippets with JSdocs less verbose? #15865

Answered by brunnerh
daviareias asked this question in Q&A
Discussion options

You must be logged in to vote

Since rest arguments are currently not supported, alternatives are limited.

If you collect the arguments into an options object, you can reduce it to one type definition, but the @render code will become longer since all properties have to be named.

{#snippet MarketCell(
  /** @type {{
    label: string,
    value: string,
    hiddenVariants: number,
    hiddenProducts: number,
    index: number | undefined,
    primary: boolean | undefined,
    global: boolean | undefined,
  }} */ options
)}
...
{/snippet}

{@render MarketCell({
  label: 'a',
  value: 'b',
  hiddenVariants: 1,
  // ...
})}

As an alternative to rest args, you could use a single tuple argument, but editor tooling when writ…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by daviareias
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants