mirror of
https://github.com/MercuryWorkshop/dreamlandjs.git
synced 2025-05-16 15:40:01 -04:00
new functional component syntax
This commit is contained in:
parent
fcc411d842
commit
2dcae6ad11
2 changed files with 20 additions and 9 deletions
25
AliceJS.d.ts
vendored
25
AliceJS.d.ts
vendored
|
@ -1,5 +1,7 @@
|
|||
declare namespace JSX {
|
||||
export type IntrinsicElements = { [index: string]: any };
|
||||
export type IntrinsicElements = {
|
||||
[index: string]: any
|
||||
};
|
||||
}
|
||||
|
||||
declare function h(
|
||||
|
@ -26,19 +28,28 @@ declare var styled: { new: typeof css, rule: typeof rule };
|
|||
|
||||
type DLCSS = string;
|
||||
|
||||
declare var $el: HTMLElement;
|
||||
|
||||
interface Element {
|
||||
$: DLComponent<any>
|
||||
$: OuterComponentTypes & { [index: string | symbol]: any }
|
||||
}
|
||||
|
||||
interface DLElement<T> extends Element {
|
||||
$: T
|
||||
$: T & OuterComponentTypes
|
||||
}
|
||||
|
||||
declare var $el: HTMLElement;
|
||||
type ComponentElement<T extends (...args: any) => any> = DLElement<ReturnType<T>>;
|
||||
|
||||
type DLComponent<T> = {
|
||||
css: DLCSS,
|
||||
type OuterComponentTypes = {
|
||||
root: Element,
|
||||
children: Element[],
|
||||
}
|
||||
type InnerComponentTypes = {
|
||||
css: DLCSS,
|
||||
mount?: () => void,
|
||||
} & T;
|
||||
}
|
||||
type ComponentTypes = OuterComponentTypes & InnerComponentTypes;
|
||||
|
||||
type Component<Public, Private> = ((this: Public & Private & ComponentTypes, _props: Public) => DLElement<Public>);
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue