This repository was archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Type definitions #90
Draft
aminya
wants to merge
14
commits into
atom:master
Choose a base branch
from
aminya:type_definitions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Type definitions #90
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
da9251d
add types entry to package.json
aminya 6fdfa60
install typescript for dev
aminya f285d5b
Etch class props
aminya 3562380
Etch element extra props
aminya 14ddafd
Etch HTML element
aminya 7dc8099
Etch SVG element
aminya e673197
Etch element's tag
aminya cc34edb
General Etch element
aminya 0d43119
Etch JSX Element
aminya 0db9838
type of etch elements' children
aminya 8c361d1
ElementClassConstructor
aminya d92745c
JSX
aminya d1fffc1
dom function
aminya bbfa43f
etch other functions
aminya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {JSX, EtchJSXElement, EtchExtraProps, Props, ChildSpec, TagSpec, ElementClassConstructor} from "./etch-element" | ||
|
||
export function dom<T extends keyof HTMLElementTagNameMap>(tag: T, props?: HTMLElementTagNameMap[T] & EtchExtraProps & Props, ...children: ChildSpec[]): EtchJSXElement | ||
export function dom<T extends keyof SVGElementTagNameMap>(tag: T, props?: SVGElementTagNameMap[T] & EtchExtraProps & Props, ...children: ChildSpec[]): EtchJSXElement | ||
export function dom<T extends JSX.ElementClass>( tag: ElementClassConstructor<T>, props: T["props"],...children: ChildSpec[]): EtchJSXElement | ||
export function dom(tag: string, props?: EtchExtraProps & Props, ...children: ChildSpec[]): EtchJSXElement | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/** Etch class props */ | ||
type Props = object | ||
|
||
/** Etch element extra props */ | ||
interface EtchExtraProps { | ||
ref?: string | ||
className?: string | ||
on?: { | ||
click?: (e: MouseEvent) => any | ||
[name: string]: ((e: any) => any) | undefined | ||
} | ||
dataset?: { | ||
[propName: string]: string | number | null | ||
} | ||
innerHTML?: string | ||
innerText?: string | ||
key?: any | ||
} | ||
|
||
/** Etch HTML element */ | ||
export interface EtchHTMLElement<Tag extends keyof HTMLElementTagNameMap> { | ||
tag: Tag | ||
props: HTMLElementTagNameMap[Tag] & EtchExtraProps & Props | ||
children: ChildSpec | ||
ambiguous: Array<object> | ||
} | ||
|
||
/** Etch SVG element */ | ||
export interface EtchSVGElement<Tag extends keyof SVGElementTagNameMap> { | ||
tag: Tag | ||
props: SVGElementTagNameMap[Tag] & EtchExtraProps & Props | ||
children?: ChildSpec | ||
ambiguous: Array<object> | ||
} | ||
|
||
|
||
/** Etch element's tag */ | ||
type TagSpec = string | ElementClassConstructor<JSX.ElementClass> | keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap | ||
|
||
/** General Etch element */ | ||
export interface EtchElement<Tag extends TagSpec> { | ||
tag: Tag | ||
props: EtchExtraProps & Props | ||
children?: ChildSpec | ||
ambiguous: Array<object> | ||
} | ||
|
||
/** Etch JSX Element */ | ||
type EtchJSXElement = | ||
| EtchHTMLElement<keyof HTMLElementTagNameMap> | ||
| EtchSVGElement<keyof SVGElementTagNameMap> | ||
| EtchElement<TagSpec> | ||
| {text: string | number} | ||
|
||
type SingleOrArray<T> = T | T[] | ||
/** type of etch elements' children */ | ||
type ChildSpec = SingleOrArray<string | number | EtchJSXElement | null> | ||
|
||
|
||
type ElementClassConstructor<T extends JSX.ElementClass> = new (props: T["props"], children: EtchJSXElement[]) => T | ||
|
||
export declare namespace JSX { | ||
type Element = EtchJSXElement | ||
type IntrinsicElements = EtchJSXElement | ||
class ElementClass { | ||
public props: Props | ||
constructor(props: Props, children?: EtchJSXElement[]) | ||
public render?(): EtchJSXElement | ||
public update(props: Props, children?: EtchJSXElement[]): Promise<void> | ||
} | ||
interface ElementAttributesProperty { | ||
props: Props // specify the property name to use | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
export * from "./etch-element" | ||
export * from "./dom" | ||
import {EtchJSXElement} from "./etch-element" | ||
|
||
export function destroy(component: any, removeNode?: boolean): Promise<void> | ||
export function destroySync(component: any, removeNode: any): void | ||
export function getScheduler(): any | ||
export function initialize(component: any): void | ||
export function render(virtualNode: EtchJSXElement, options?: any): Node | ||
export function setScheduler(customScheduler: any): void | ||
export function update(component: any, replaceNode?: boolean): Promise<void> | ||
export function updateSync(component: any, replaceNode?: boolean): void |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dom.tags are missing. I need to write a script to generate those instead of writing them by hand.