solid-labels icon indicating copy to clipboard operation
solid-labels copied to clipboard

Add destructuring defaults to the docs

Open DaniGuardiola opened this issue 1 year ago • 4 comments

Edit: the feature is supported, but the docs are outdated

Solid labels supports destructuring with defaults, but the docs are outdated and, in fact, explicitly state that it's not supported. The docs need to be updated to explain the feature.

Previous content:

Taking this babel plugin as an example, it should be doable with mergeProps:

// Default props using `mergeProps`
import { Component } from 'solid-js'
const MyComp: Component<...> = (
  { a = 1, b = 2, c = 3 } = defaultProps
) => {a; b; c;}

//  ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
import { Component, mergeProps } from 'solid-js'
const MyComp: Component<...> = props => {
  props = mergeProps(defaultProps, { a: 1, b: 2, c: 3 }, props);
  props.a; props.b; props.c;
}

Wondering if this is something that could be supported here? Thanks!

DaniGuardiola avatar Aug 14 '22 20:08 DaniGuardiola

Default props are already supported through $destructure and $component

Fun fact: the default props feature in that plugin is based on my plugin.

lxsmnsyc avatar Aug 15 '22 02:08 lxsmnsyc

Oh okay, good to know, seems like the docs are outdated then though:

  • https://github.com/lxsmnsyc/solid-labels/blob/main/docs/ctf.md#destructure

And follow up question, are they not supported through labels and comments?

  • https://github.com/lxsmnsyc/solid-labels/blob/main/docs/labels.md#destructure
  • https://github.com/lxsmnsyc/solid-labels/blob/main/docs/comments.md#destructure

DaniGuardiola avatar Aug 15 '22 12:08 DaniGuardiola

they share the same features so yes

lxsmnsyc avatar Aug 15 '22 13:08 lxsmnsyc

Nice! I'm gonna rename this issue then to focus on the docs.

DaniGuardiola avatar Aug 15 '22 13:08 DaniGuardiola

Well, that took a while

lxsmnsyc avatar Feb 18 '23 17:02 lxsmnsyc