-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
170 additions
and
7 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
coverage/ | ||
node_modules/ | ||
yarn.lock | ||
!lib/components.d.ts |
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,57 @@ | ||
/** | ||
* Basic functional component: given props, returns an element. | ||
* | ||
* @typeParam ComponentProps | ||
* Props type. | ||
* @param props | ||
* Props. | ||
* @returns | ||
* Result. | ||
*/ | ||
export type FunctionComponent<ComponentProps> = ( | ||
props: ComponentProps | ||
) => JSX.Element | string | null | undefined | ||
|
||
/** | ||
* Class component: given props, returns an instance. | ||
* | ||
* @typeParam ComponentProps | ||
* Props type. | ||
* @param props | ||
* Props. | ||
* @returns | ||
* Instance. | ||
*/ | ||
export type ClassComponent<ComponentProps> = new ( | ||
props: ComponentProps | ||
) => JSX.ElementClass | ||
|
||
/** | ||
* Function or class component. | ||
* | ||
* You can access props at `JSX.IntrinsicElements`. | ||
* For example, to find props for `a`, use `JSX.IntrinsicElements['a']`. | ||
* | ||
* @typeParam ComponentProps | ||
* Props type. | ||
*/ | ||
export type Component<ComponentProps> = | ||
| FunctionComponent<ComponentProps> | ||
| ClassComponent<ComponentProps> | ||
|
||
/** | ||
* Possible components to use. | ||
* | ||
* Each key is a tag name typed in `JSX.IntrinsicElements`. | ||
* Each value is a component accepting the corresponding props or a different | ||
* tag name. | ||
* | ||
* You can access props at `JSX.IntrinsicElements`. | ||
* For example, to find props for `a`, use `JSX.IntrinsicElements['a']`. | ||
*/ | ||
export type Components = { | ||
[TagName in keyof JSX.IntrinsicElements]: | ||
| Component<JSX.IntrinsicElements[TagName]> | ||
| keyof JSX.IntrinsicElements | ||
} |
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,2 @@ | ||
// TypeScript only. | ||
export {} |
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
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
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