Skip to content

Commit 6830a48

Browse files
committed
Add some basic types
1 parent 8ad66ad commit 6830a48

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/index.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
11
import { createState, createRoot, produce } from "solid-js";
22

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+
313
// etch.initialize
4-
export function initialize(component) {
14+
export function initialize(component: EtchSolidComponent) {
515

616
const $originUpdate = component.update,
717
$originDestroy = component.destroy;
818

919
// handle the changes in the states
10-
let dispose;
20+
let dispose: () => void;
1121
const d = Object.getOwnPropertyDescriptors(component.__proto__);
1222
const [$state, setState] = createState(
1323
Object.assign(Object.create(Object.prototype, d), component)
1424
);
1525

1626
// handle updating
17-
function update(...args) {
27+
function update(...args: any[]) {
1828
setState(produce((s) => $originUpdate.call(s, ...args)));
1929
}
2030

0 commit comments

Comments
 (0)