From 03ae76d4ec1efd6f1ee51d9f8861ec284b808ed2 Mon Sep 17 00:00:00 2001 From: Hernan Rajchert Date: Thu, 29 Nov 2018 18:54:27 -0300 Subject: [PATCH] chore: update definitions Update definitions to match those defined by the library author --- types/unist/index.d.ts | 39 ++++++++++++++++++++++++++++++-------- types/unist/unist-tests.ts | 2 -- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/types/unist/index.d.ts b/types/unist/index.d.ts index 7433ddcc13..389b26e04f 100644 --- a/types/unist/index.d.ts +++ b/types/unist/index.d.ts @@ -1,40 +1,63 @@ // Type definitions for Unist 2.0 -// Project: https://github.com/syntax-tree/unist +// Project: https://github.com/syntax-tree/unist-ts // Definitions by: bizen241 // Jun Lu +// Hernan Rajchert +// Titus Wormer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 +// TypeScript Version: 3.1 +export as namespace Unist + +// 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; + + // Location of a node in a source document. + // Must not be present if a node is generated. position?: Position; } export interface Data { - [key: string]: any; + [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; - /** >= 1 */ - indent?: number[]; + + // Start column at each index (plus start line) in the source region, + // for elements that span multiple lines. + indent: number[]; } +// One place in a source file. export interface Point { - /** >= 1 */ + // Line in a source file (1-indexed integer). line: number; - /** >= 1 */ + + // Column in a source file (1-indexed integer). column: number; - /** >= 0 */ + + // Character in a source file (0-indexed integer). offset?: number; } +// 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: any; } diff --git a/types/unist/unist-tests.ts b/types/unist/unist-tests.ts index 3cb69bcc76..9ba2dc06d5 100644 --- a/types/unist/unist-tests.ts +++ b/types/unist/unist-tests.ts @@ -1,5 +1,3 @@ -import * as Unist from 'unist'; - const data: Unist.Data = { string: 'string', number: 1,