Skip to content

Commit 82bf759

Browse files
committed
Add JSDoc based types
1 parent 0637355 commit 82bf759

11 files changed

+313
-180
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.DS_Store
2+
*.d.ts
23
*.log
34
coverage/
45
node_modules/

Diff for: hastscript-tests.ts

-18
This file was deleted.

Diff for: index.d.ts

+45-29
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,45 @@
1-
// TypeScript Version: 3.5
2-
3-
import {Element, Properties, Node} from 'hast'
4-
5-
/**
6-
* DSL to create virtual hast trees for HTML or SVG
7-
*
8-
* @param selector Simple CSS selector
9-
* @param children (Lists of) child nodes
10-
*/
11-
declare function hastscript(
12-
selector?: string,
13-
children?: string | Node | Array<string | Node>
14-
): Element
15-
16-
/**
17-
* DSL to create virtual hast trees for HTML or SVG
18-
*
19-
* @param selector Simple CSS selector
20-
* @param properties Map of properties
21-
* @param children (Lists of) child nodes
22-
*/
23-
declare function hastscript(
24-
selector?: string,
25-
properties?: Properties,
26-
children?: string | Node | Array<string | Node>
27-
): Element
28-
29-
export = hastscript
1+
export function h(): HastRoot
2+
export function h(selector: null | undefined, ...children: HChild[]): HastRoot
3+
export function h(
4+
selector: string,
5+
properties: HProperties,
6+
...children: HChild[]
7+
): HastElement
8+
export function h(selector: string, ...children: HChild[]): HastElement
9+
export function s(): HastRoot
10+
export function s(selector: null | undefined, ...children: HChild[]): HastRoot
11+
export function s(
12+
selector: string,
13+
properties: HProperties,
14+
...children: HChild[]
15+
): HastElement
16+
export function s(selector: string, ...children: HChild[]): HastElement
17+
export type HastRoot = import('hast').Root
18+
export type HastElement = import('hast').Element
19+
export type Properties = import('hast').Properties
20+
export type HastChild = HastRoot['children'][number]
21+
export type Info = import('property-information/lib/util/schema').Schema['property'][string]
22+
export type Schema =
23+
| import('property-information/lib/util/schema').Schema
24+
| import('property-information/lib/util/schema').Schema
25+
export type HStyleValue = string | number
26+
export type HStyle = {
27+
[x: string]: HStyleValue
28+
}
29+
export type HPrimitiveValue = string | number | boolean | null | undefined
30+
export type HArrayValue = Array<string | number>
31+
export type HPropertyValue = HPrimitiveValue | (string | number)[]
32+
export type HProperties = {
33+
[property: string]:
34+
| {
35+
[x: string]: HStyleValue
36+
}
37+
| HPropertyValue
38+
}
39+
export type HPrimitiveChild = string | number | null | undefined
40+
export type HNodeChild = HastChild | HastRoot
41+
export type HArrayChild = Array<HPrimitiveChild | HNodeChild>
42+
export type HChild =
43+
| HPrimitiveChild
44+
| HNodeChild
45+
| (HPrimitiveChild | HNodeChild)[]

0 commit comments

Comments
 (0)