File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change 1
1
import { createState , createRoot , produce } from "solid-js" ;
2
2
3
+
4
+ type EtchSolidElement = any
5
+ interface EtchSolidComponent {
6
+ element : EtchSolidElement
7
+ render : ( ) => any
8
+ update : ( ...args : any [ ] ) => void
9
+ destroy : ( ) => void
10
+ __proto__ : any
11
+ }
12
+
3
13
// etch.initialize
4
- export function initialize ( component ) {
14
+ export function initialize ( component : EtchSolidComponent ) {
5
15
6
16
const $originUpdate = component . update ,
7
17
$originDestroy = component . destroy ;
8
18
9
19
// handle the changes in the states
10
- let dispose ;
20
+ let dispose : ( ) => void ;
11
21
const d = Object . getOwnPropertyDescriptors ( component . __proto__ ) ;
12
22
const [ $state , setState ] = createState (
13
23
Object . assign ( Object . create ( Object . prototype , d ) , component )
14
24
) ;
15
25
16
26
// handle updating
17
- function update ( ...args ) {
27
+ function update ( ...args : any [ ] ) {
18
28
setState ( produce ( ( s ) => $originUpdate . call ( s , ...args ) ) ) ;
19
29
}
20
30
You can’t perform that action at this time.
0 commit comments