@@ -11,15 +11,25 @@ Usage with examples:
1111
1212``` jsx
1313// Use the `Component` type to mark components that will be transformed by the plugin
14- import { Component } from ' solid-js'
14+ import type { Component } from ' solid-js'
1515const MyComp: Component <... > = ({ a, b, c }) => {a; b; c;};
1616
1717// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓ The above code will compile to
18- import { Component } from ' solid-js'
18+ import type { Component } from ' solid-js'
1919const MyComp: Component <... > = props => {props .a ; props .b ; props .c ;}
2020
2121
2222
23+ // Also works with the `ParentComponent` type
24+ import type { ParentComponent } from ' solid-js'
25+ const MyComp: ParentComponent <... > = ({ a, b, c }) => {a; b; c;};
26+
27+ // ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
28+ import type { ParentComponent } from ' solid-js'
29+ const MyComp: ParentComponent <... > = props => {props .a ; props .b ; props .c ;}
30+
31+
32+
2333// You can use a compile time function instead of using the `Component` type (needed for vanilla JS)
2434import { component } from ' undestructure-macros'
2535const MyComp = component (({ a, b, c }) => {a; b; c;})
@@ -30,13 +40,13 @@ const MyComp = props => {props.a; props.b; props.c;}
3040
3141
3242// Default props using `mergeProps`
33- import { Component } from ' solid-js'
43+ import type { Component } from ' solid-js'
3444const MyComp: Component <... > = (
3545 { a = 1 , b = 2 , c = 3 } = defaultProps
3646) => {a; b; c;}
3747
3848// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
39- import { Component , mergeProps } from ' solid-js'
49+ import { type Component , mergeProps } from ' solid-js'
4050const MyComp: Component <... > = props => {
4151 props = mergeProps (defaultProps, { a: 1 , b: 2 , c: 3 }, props);
4252 props .a ; props .b ; props .c ;
@@ -45,21 +55,21 @@ const MyComp: Component<...> = props => {
4555
4656
4757// Rename props
48- import { Component } from ' solid-js'
58+ import type { Component } from ' solid-js'
4959const MyComp: Component <... > = ({ a: d, b: e, c: f }) => {d; e; f;}
5060
5161// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
52- import { Component , mergeProps } from ' solid-js'
62+ import { type Component , mergeProps } from ' solid-js'
5363const MyComp: Component <... > = props => {props .a ; props .b ; props .c ;}
5464
5565
5666
5767// Rest element destructuring using `splitProps`
58- import { Component } from ' solid-js'
68+ import type { Component } from ' solid-js'
5969const MyComp: Component <... > = ({ a, b, c, ... other }) => {a; b; c; other;}
6070
6171// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
62- import { Component , splitProps } from ' solid-js'
72+ import { type Component , splitProps } from ' solid-js'
6373const MyComp: Component <... > = props => {
6474 let other;
6575 [props, other] = splitProps (props, [" a" , " b" , " c" ]);
@@ -69,15 +79,15 @@ const MyComp: Component<...> = props => {
6979
7080
7181// You can nest components
72- import { Component } from ' solid-js'
82+ import type { Component } from ' solid-js'
7383const Parent: Component <... > = ({ a, b }) => {
7484 const Child: Component <... > = ({ c, d }) => {
7585 a; b; c; d;
7686 }
7787}
7888
7989// ↓ ↓ ↓ ↓ ↓ ↓ ↓ ↓
80- import { Component } from ' solid-js'
90+ import type { Component } from ' solid-js'
8191const Parent: Component <... > = props1 => {
8292 const Child: Component <... > = props2 => {
8393 props1 .a ; props1 .b ; props2 .c ; props2 .d ;
@@ -99,7 +109,7 @@ In both cases you can use the 'import as' syntax.
99109Examples:
100110
101111``` tsx
102- import { Component } from ' solid-js'
112+ import type { Component } from ' solid-js'
103113
104114const MyComponent: Component = // ...
105115```
@@ -111,15 +121,15 @@ const MyComponent: Solid.Component = // ...
111121```
112122
113123``` tsx
114- import { Component as ComponentAlias } from ' solid-js'
124+ import type { Component as ComponentAlias } from ' solid-js'
115125
116126const MyComponent: ComponentAlias = // ...
117127```
118128
119129This example won't work:
120130
121131``` tsx
122- import { Component } from ' solid-js'
132+ import type { Component } from ' solid-js'
123133
124134type ComponentAlias = Component
125135
0 commit comments