mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[unist]: add types (#19472)
This commit is contained in:
parent
0f62f0016e
commit
ac52d79dde
39
types/unist/index.d.ts
vendored
Normal file
39
types/unist/index.d.ts
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
// Type definitions for Unist 1.0
|
||||
// Project: https://github.com/syntax-tree/unist
|
||||
// Definitions by: bizen241 <https://github.com/bizen241>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
export interface Node {
|
||||
type: string;
|
||||
data?: Data;
|
||||
position?: Position;
|
||||
}
|
||||
|
||||
export interface Data {
|
||||
[key: string]: string | number | object | any[] | boolean | null;
|
||||
}
|
||||
|
||||
export interface Position {
|
||||
start: Point;
|
||||
end: Point;
|
||||
/** >= 1 */
|
||||
indent?: number[];
|
||||
}
|
||||
|
||||
export interface Point {
|
||||
/** >= 1 */
|
||||
line: number;
|
||||
/** >= 1 */
|
||||
column: number;
|
||||
/** >= 0 */
|
||||
offset?: number;
|
||||
}
|
||||
|
||||
export interface Parent extends Node {
|
||||
children: Node[];
|
||||
}
|
||||
|
||||
export interface Text extends Node {
|
||||
value: string;
|
||||
}
|
||||
22
types/unist/tsconfig.json
Normal file
22
types/unist/tsconfig.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"unist-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/unist/tslint.json
Normal file
1
types/unist/tslint.json
Normal file
@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
49
types/unist/unist-tests.ts
Normal file
49
types/unist/unist-tests.ts
Normal file
@ -0,0 +1,49 @@
|
||||
import * as Unist from 'unist';
|
||||
|
||||
const data: Unist.Data = {
|
||||
string: 'string',
|
||||
number: 1,
|
||||
object: {
|
||||
key: 'value',
|
||||
},
|
||||
array: [],
|
||||
boolean: true,
|
||||
null: null,
|
||||
};
|
||||
|
||||
const point: Unist.Point = {
|
||||
line: 1,
|
||||
column: 1,
|
||||
offset: 0,
|
||||
};
|
||||
|
||||
const position: Unist.Position = {
|
||||
start: point,
|
||||
end: point,
|
||||
indent: [
|
||||
1,
|
||||
],
|
||||
};
|
||||
|
||||
const node: Unist.Node = {
|
||||
type: 'node',
|
||||
data,
|
||||
position,
|
||||
};
|
||||
|
||||
const text: Unist.Text = {
|
||||
type: 'text',
|
||||
data,
|
||||
position,
|
||||
value: 'value',
|
||||
};
|
||||
|
||||
const parent: Unist.Parent = {
|
||||
type: 'parent',
|
||||
data,
|
||||
position,
|
||||
children: [
|
||||
node,
|
||||
text,
|
||||
],
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user