@types/unist
Advanced tools
Comparing version 2.0.5 to 2.0.6
@@ -9,2 +9,3 @@ // Type definitions for non-npm package Unist 2.0 | ||
// Ben Moon <https://github.com/GuiltyDolphin> | ||
// JounQin <https://github.com/JounQin> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
@@ -15,4 +16,6 @@ // TypeScript Version: 3.0 | ||
* Syntactic units in unist syntax trees are called nodes. | ||
* | ||
* @typeParam TData Information from the ecosystem. Useful for more specific {@link Node.data}. | ||
*/ | ||
export interface Node { | ||
export interface Node<TData extends object = Data> { | ||
/** | ||
@@ -26,3 +29,3 @@ * The variant of a node. | ||
*/ | ||
data?: Data | undefined; | ||
data?: TData | undefined; | ||
@@ -86,9 +89,21 @@ /** | ||
/** | ||
* Util for extracting type of {@link Node.data} | ||
* | ||
* @typeParam TNode Specific node type such as {@link Node} with {@link Data}, {@link Literal}, etc. | ||
* | ||
* @example `NodeData<Node<{ key: string }>>` -> `{ key: string }` | ||
*/ | ||
export type NodeData<TNode extends Node<object>> = TNode extends Node<infer TData> ? TData : never; | ||
/** | ||
* Nodes containing other nodes. | ||
* | ||
* @typeParam ChildNode Node item of {@link Parent.children} | ||
*/ | ||
export interface Parent extends Node { | ||
export interface Parent<ChildNode extends Node<object> = Node, TData extends object = NodeData<ChildNode>> | ||
extends Node<TData> { | ||
/** | ||
* List representing the children of a node. | ||
*/ | ||
children: Node[]; | ||
children: ChildNode[]; | ||
} | ||
@@ -98,5 +113,7 @@ | ||
* Nodes containing a value. | ||
* | ||
* @typeParam Value Specific value type of {@link Literal.value} such as `string` for `Text` node | ||
*/ | ||
export interface Literal extends Node { | ||
value: unknown; | ||
export interface Literal<Value = unknown, TData extends object = Data> extends Node<TData> { | ||
value: Value; | ||
} |
{ | ||
"name": "@types/unist", | ||
"version": "2.0.5", | ||
"version": "2.0.6", | ||
"description": "TypeScript definitions for Unist", | ||
@@ -37,2 +37,7 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/unist", | ||
"githubUsername": "GuiltyDolphin" | ||
}, | ||
{ | ||
"name": "JounQin", | ||
"url": "https://github.com/JounQin", | ||
"githubUsername": "JounQin" | ||
} | ||
@@ -49,4 +54,4 @@ ], | ||
"dependencies": {}, | ||
"typesPublisherContentHash": "8ccad5f642f0db93deb67cde3530f4bd2b5eed2ebdb46897bbcc1247775e5ef9", | ||
"typesPublisherContentHash": "da5f2c3f967fa07869161991244bb7f9a237ac20494b902ffcb9108deb9b4e12", | ||
"typeScriptVersion": "3.6" | ||
} |
@@ -9,106 +9,5 @@ # Installation | ||
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/unist. | ||
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/unist/index.d.ts) | ||
````ts | ||
// Type definitions for non-npm package Unist 2.0 | ||
// Project: https://github.com/syntax-tree/unist | ||
// Definitions by: bizen241 <https://github.com/bizen241> | ||
// Jun Lu <https://github.com/lujun2> | ||
// Hernan Rajchert <https://github.com/hrajchert> | ||
// Titus Wormer <https://github.com/wooorm> | ||
// Junyoung Choi <https://github.com/rokt33r> | ||
// Ben Moon <https://github.com/GuiltyDolphin> | ||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped | ||
// TypeScript Version: 3.0 | ||
/** | ||
* Syntactic units in unist syntax trees are called nodes. | ||
*/ | ||
export interface Node { | ||
/** | ||
* The variant of a node. | ||
*/ | ||
type: string; | ||
/** | ||
* Information from the ecosystem. | ||
*/ | ||
data?: Data | undefined; | ||
/** | ||
* Location of a node in a source document. | ||
* Must not be present if a node is generated. | ||
*/ | ||
position?: Position | undefined; | ||
} | ||
/** | ||
* Information associated by the ecosystem with the node. | ||
* Space is guaranteed to never be specified by unist or specifications | ||
* implementing unist. | ||
*/ | ||
export interface Data { | ||
[key: string]: unknown; | ||
} | ||
/** | ||
* Location of a node in a source file. | ||
*/ | ||
export interface Position { | ||
/** | ||
* Place of the first character of the parsed source region. | ||
*/ | ||
start: Point; | ||
/** | ||
* Place of the first character after the parsed source region. | ||
*/ | ||
end: Point; | ||
/** | ||
* Start column at each index (plus start line) in the source region, | ||
* for elements that span multiple lines. | ||
*/ | ||
indent?: number[] | undefined; | ||
} | ||
/** | ||
* One place in a source file. | ||
*/ | ||
export interface Point { | ||
/** | ||
* Line in a source file (1-indexed integer). | ||
*/ | ||
line: number; | ||
/** | ||
* Column in a source file (1-indexed integer). | ||
*/ | ||
column: number; | ||
/** | ||
* Character in a source file (0-indexed integer). | ||
*/ | ||
offset?: number | undefined; | ||
} | ||
/** | ||
* Nodes containing other nodes. | ||
*/ | ||
export interface Parent extends Node { | ||
/** | ||
* List representing the children of a node. | ||
*/ | ||
children: Node[]; | ||
} | ||
/** | ||
* Nodes containing a value. | ||
*/ | ||
export interface Literal extends Node { | ||
value: unknown; | ||
} | ||
```` | ||
### Additional Details | ||
* Last updated: Mon, 05 Jul 2021 15:31:19 GMT | ||
* Last updated: Thu, 15 Jul 2021 00:31:23 GMT | ||
* Dependencies: none | ||
@@ -118,2 +17,2 @@ * Global values: none | ||
# Credits | ||
These definitions were written by [bizen241](https://github.com/bizen241), [Jun Lu](https://github.com/lujun2), [Hernan Rajchert](https://github.com/hrajchert), [Titus Wormer](https://github.com/wooorm), [Junyoung Choi](https://github.com/rokt33r), and [Ben Moon](https://github.com/GuiltyDolphin). | ||
These definitions were written by [bizen241](https://github.com/bizen241), [Jun Lu](https://github.com/lujun2), [Hernan Rajchert](https://github.com/hrajchert), [Titus Wormer](https://github.com/wooorm), [Junyoung Choi](https://github.com/rokt33r), [Ben Moon](https://github.com/GuiltyDolphin), and [JounQin](https://github.com/JounQin). |
102
6601
17