feat: use go tool

This commit is contained in:
2026-07-03 19:24:01 -04:00
parent 39548b4332
commit 4d0cab1fe0
1542 changed files with 252399 additions and 14 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
+69
View File
@@ -0,0 +1,69 @@
# Installation
> `npm install --save @types/debug`
# Summary
This package contains type definitions for debug (https://github.com/debug-js/debug).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/debug.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/debug/index.d.ts)
````ts
declare var debug: debug.Debug & { debug: debug.Debug; default: debug.Debug };
export = debug;
export as namespace debug;
declare namespace debug {
interface Debug {
(namespace: string): Debugger;
coerce: (val: any) => any;
disable: () => string;
enable: (namespaces: string) => void;
enabled: (namespaces: string) => boolean;
formatArgs: (this: Debugger, args: any[]) => void;
log: (...args: any[]) => any;
selectColor: (namespace: string) => string | number;
humanize: typeof import("ms");
names: string[];
skips: string[];
formatters: Formatters;
inspectOpts?: {
hideDate?: boolean | number | null;
colors?: boolean | number | null;
depth?: boolean | number | null;
showHidden?: boolean | number | null;
};
}
type IDebug = Debug;
interface Formatters {
[formatter: string]: (v: any) => string;
}
type IDebugger = Debugger;
interface Debugger {
(formatter: any, ...args: any[]): void;
color: string;
diff: number;
enabled: boolean;
log: (...args: any[]) => any;
namespace: string;
destroy: () => boolean;
extend: (namespace: string, delimiter?: string) => Debugger;
}
}
````
### Additional Details
* Last updated: Thu, 19 Mar 2026 06:47:22 GMT
* Dependencies: [@types/ms](https://npmjs.com/package/@types/ms)
# Credits
These definitions were written by [Seon-Wook Park](https://github.com/swook), [Gal Talmor](https://github.com/galtalmor), [John McLaughlin](https://github.com/zamb3zi), [Brasten Sager](https://github.com/brasten), [Nicolas Penin](https://github.com/npenin), [Kristian Brünn](https://github.com/kristianmitk), and [Caleb Gregory](https://github.com/calebgregory).
+50
View File
@@ -0,0 +1,50 @@
declare var debug: debug.Debug & { debug: debug.Debug; default: debug.Debug };
export = debug;
export as namespace debug;
declare namespace debug {
interface Debug {
(namespace: string): Debugger;
coerce: (val: any) => any;
disable: () => string;
enable: (namespaces: string) => void;
enabled: (namespaces: string) => boolean;
formatArgs: (this: Debugger, args: any[]) => void;
log: (...args: any[]) => any;
selectColor: (namespace: string) => string | number;
humanize: typeof import("ms");
names: string[];
skips: string[];
formatters: Formatters;
inspectOpts?: {
hideDate?: boolean | number | null;
colors?: boolean | number | null;
depth?: boolean | number | null;
showHidden?: boolean | number | null;
};
}
type IDebug = Debug;
interface Formatters {
[formatter: string]: (v: any) => string;
}
type IDebugger = Debugger;
interface Debugger {
(formatter: any, ...args: any[]): void;
color: string;
diff: number;
enabled: boolean;
log: (...args: any[]) => any;
namespace: string;
destroy: () => boolean;
extend: (namespace: string, delimiter?: string) => Debugger;
}
}
+58
View File
@@ -0,0 +1,58 @@
{
"name": "@types/debug",
"version": "4.1.13",
"description": "TypeScript definitions for debug",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/debug",
"license": "MIT",
"contributors": [
{
"name": "Seon-Wook Park",
"githubUsername": "swook",
"url": "https://github.com/swook"
},
{
"name": "Gal Talmor",
"githubUsername": "galtalmor",
"url": "https://github.com/galtalmor"
},
{
"name": "John McLaughlin",
"githubUsername": "zamb3zi",
"url": "https://github.com/zamb3zi"
},
{
"name": "Brasten Sager",
"githubUsername": "brasten",
"url": "https://github.com/brasten"
},
{
"name": "Nicolas Penin",
"githubUsername": "npenin",
"url": "https://github.com/npenin"
},
{
"name": "Kristian Brünn",
"githubUsername": "kristianmitk",
"url": "https://github.com/kristianmitk"
},
{
"name": "Caleb Gregory",
"githubUsername": "calebgregory",
"url": "https://github.com/calebgregory"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/debug"
},
"scripts": {},
"dependencies": {
"@types/ms": "*"
},
"peerDependencies": {},
"typesPublisherContentHash": "1c506e100366b85350ff1c28c9cf4cc09e9a07275546bb050993c241c9821cd9",
"typeScriptVersion": "5.2"
}
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
+15
View File
@@ -0,0 +1,15 @@
# Installation
> `npm install --save @types/katex`
# Summary
This package contains type definitions for katex (http://khan.github.io/KaTeX/).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/katex.
### Additional Details
* Last updated: Sat, 10 Jan 2026 00:47:09 GMT
* Dependencies: none
# Credits
These definitions were written by [Kevin Nguyen](https://github.com/knguyen0125), [bLue](https://github.com/dreamerblue), [Sebastian Weigand](https://github.com/s-weigand), [sapphi-red](https://github.com/sapphi-red), and [Stefaans](https://github.com/Stefaans).
+67
View File
@@ -0,0 +1,67 @@
import { KatexOptions } from "../index.js";
declare namespace renderMathInElement {
interface RenderMathInElementSpecificOptionsDelimiters {
/**
* A string which starts the math expression (i.e. the left delimiter)
*/
left: string;
/**
* A string which ends the math expression (i.e. the right delimiter)
*/
right: string;
/**
* A boolean of whether the math in the expression should be rendered in display mode or not
*/
display: boolean;
}
interface RenderMathInElementSpecificOptions {
/**
* A list of delimiters to look for math
*
* @default [
* {left: "$$", right: "$$", display: true},
* {left: "\\(", right: "\\)", display: false},
* {left: "\\[", right: "\\]", display: true}
* ]
*/
delimiters?: readonly RenderMathInElementSpecificOptionsDelimiters[] | undefined;
/**
* A list of DOM node types to ignore when recursing through
*
* @default ["script", "noscript", "style", "textarea", "pre", "code"]
*/
ignoredTags?: ReadonlyArray<keyof HTMLElementTagNameMap> | undefined;
/**
* A list of DOM node class names to ignore when recursing through
*
* @default []
*/
ignoredClasses?: string[] | undefined;
/**
* A callback method returning a message and an error stack in case of an critical error during rendering
* @param msg Message generated by KaTeX
* @param err Caught error
*
* @default console.error
*/
errorCallback?(msg: string, err: Error): void;
}
/**
* renderMathInElement options contain KaTeX render options and renderMathInElement specific options
*/
type RenderMathInElementOptions = KatexOptions & RenderMathInElementSpecificOptions;
}
/**
* Auto-render TeX expressions in HTML element
* @param elem HTML element to auto-render
* @param options Render options
*/
declare function renderMathInElement(elem: HTMLElement, options?: renderMathInElement.RenderMathInElementOptions): void;
export = renderMathInElement;
export as namespace renderMathInElement;
+151
View File
@@ -0,0 +1,151 @@
export interface TrustContext {
command: string;
url: string;
protocol: string;
}
/** Documentation: https://katex.org/docs/options.html */
export interface KatexOptions {
/**
* If `true`, math will be rendered in display mode
* (math in display style and center math on page)
*
* If `false`, math will be rendered in inline mode
* @default false
*/
displayMode?: boolean | undefined;
/**
* Determines the markup language of the output. The valid choices are:
* - `html`: Outputs KaTeX in HTML only.
* - `mathml`: Outputs KaTeX in MathML only.
* - `htmlAndMathml`: Outputs HTML for visual rendering
* and includes MathML for accessibility.
*
* @default 'htmlAndMathml'
*/
output?: "html" | "mathml" | "htmlAndMathml" | undefined;
/**
* If `true`, display math has \tags rendered on the left
* instead of the right, like \usepackage[leqno]{amsmath} in LaTeX.
*
* @default false
*/
leqno?: boolean | undefined;
/**
* If `true`, display math renders flush left with a 2em left margin,
* like \documentclass[fleqn] in LaTeX with the amsmath package.
*
* @default false
*/
fleqn?: boolean | undefined;
/**
* If `true`, KaTeX will throw a `ParseError` when
* it encounters an unsupported command or invalid LaTex
*
* If `false`, KaTeX will render unsupported commands as
* text, and render invalid LaTeX as its source code with
* hover text giving the error, in color given by errorColor
* @default true
*/
throwOnError?: boolean | undefined;
/**
* A Color string given in format `#XXX` or `#XXXXXX`
*/
errorColor?: string | undefined;
/**
* A collection of custom macros.
*
* See `src/macros.js` for its usage
*/
macros?: any;
/**
* Specifies a minimum thickness, in ems, for fraction lines,
* \sqrt top lines, {array} vertical lines, \hline, \hdashline,
* \underline, \overline, and the borders of \fbox, \boxed, and
* \fcolorbox.
*/
minRuleThickness?: number | undefined;
/**
* If `true`, `\color` will work like LaTeX's `\textcolor`
* and takes 2 arguments
*
* If `false`, `\color` will work like LaTeX's `\color`
* and takes 1 argument
*
* In both cases, `\textcolor` works as in LaTeX
*
* @default false
*/
colorIsTextColor?: boolean | undefined;
/**
* All user-specified sizes will be caped to `maxSize` ems
*
* If set to Infinity, users can make elements and space
* arbitrarily large
*
* @default Infinity
*/
maxSize?: number | undefined;
/**
* Limit the number of macro expansions to specified number
*
* If set to `Infinity`, marco expander will try to fully expand
* as in LaTex
*
* @default 1000
*/
maxExpand?: number | undefined;
/**
* If `false` or `"ignore"`, allow features that make
* writing in LaTex convenient but not supported by LaTex
*
* If `true` or `"error"`, throw an error for such transgressions
*
* If `"warn"`, warn about behavior via `console.warn`
*
* @default "warn"
*/
strict?: boolean | string | Function | undefined;
/**
* If `false` (do not trust input), prevent any commands that could enable adverse behavior, rendering them instead in errorColor.
*
* If `true` (trust input), allow all such commands.
*
* @default false
*/
trust?: boolean | ((context: TrustContext) => boolean) | undefined;
/**
* Place KaTeX code in the global group.
*
* @default false
*/
globalGroup?: boolean | undefined;
}
/**
* KaTeX error, usually during parsing.
*/
export class ParseError implements Error {
constructor(message: string, lexer: any, position: number);
name: string;
message: string;
position: number;
}
/**
* Renders a TeX expression into the specified DOM element
* @param tex A TeX expression
* @param element The DOM element to render into
* @param options KaTeX options
*/
export function render(tex: string, element: HTMLElement, options?: KatexOptions): void;
/**
* Renders a TeX expression into an HTML string
* @param tex A TeX expression
* @param options KaTeX options
*/
export function renderToString(tex: string, options?: KatexOptions): string;
export as namespace katex;
+46
View File
@@ -0,0 +1,46 @@
{
"name": "@types/katex",
"version": "0.16.8",
"description": "TypeScript definitions for katex",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/katex",
"license": "MIT",
"contributors": [
{
"name": "Kevin Nguyen",
"githubUsername": "knguyen0125",
"url": "https://github.com/knguyen0125"
},
{
"name": "bLue",
"githubUsername": "dreamerblue",
"url": "https://github.com/dreamerblue"
},
{
"name": "Sebastian Weigand",
"githubUsername": "s-weigand",
"url": "https://github.com/s-weigand"
},
{
"name": "sapphi-red",
"githubUsername": "sapphi-red",
"url": "https://github.com/sapphi-red"
},
{
"name": "Stefaans",
"githubUsername": "Stefaans",
"url": "https://github.com/Stefaans"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/katex"
},
"scripts": {},
"dependencies": {},
"peerDependencies": {},
"typesPublisherContentHash": "843b74923cb5d38471fb372b663c3c3c10e8f5d383d24b56a11f1e3d2d122e5a",
"typeScriptVersion": "5.2"
}
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
+82
View File
@@ -0,0 +1,82 @@
# Installation
> `npm install --save @types/ms`
# Summary
This package contains type definitions for ms (https://github.com/vercel/ms).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ms.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ms/index.d.ts)
````ts
/**
* Short/Long format for `value`.
*
* @param {Number} value
* @param {{long: boolean}} options
* @return {String}
*/
declare function ms(value: number, options?: { long: boolean }): string;
/**
* Parse the given `value` and return milliseconds.
*
* @param {ms.StringValue} value
* @return {Number}
*/
declare function ms(value: ms.StringValue): number;
declare namespace ms {
// Unit, UnitAnyCase, and StringValue are backported from ms@3
// https://github.com/vercel/ms/blob/8b5923d1d86c84a9f6aba8022d416dcf2361aa8d/src/index.ts
type Unit =
| "Years"
| "Year"
| "Yrs"
| "Yr"
| "Y"
| "Weeks"
| "Week"
| "W"
| "Days"
| "Day"
| "D"
| "Hours"
| "Hour"
| "Hrs"
| "Hr"
| "H"
| "Minutes"
| "Minute"
| "Mins"
| "Min"
| "M"
| "Seconds"
| "Second"
| "Secs"
| "Sec"
| "s"
| "Milliseconds"
| "Millisecond"
| "Msecs"
| "Msec"
| "Ms";
type UnitAnyCase = Unit | Uppercase<Unit> | Lowercase<Unit>;
type StringValue =
| `${number}`
| `${number}${UnitAnyCase}`
| `${number} ${UnitAnyCase}`;
}
export = ms;
````
### Additional Details
* Last updated: Thu, 16 Jan 2025 21:02:45 GMT
* Dependencies: none
# Credits
These definitions were written by [Zhiyuan Wang](https://github.com/danny8002).
+63
View File
@@ -0,0 +1,63 @@
/**
* Short/Long format for `value`.
*
* @param {Number} value
* @param {{long: boolean}} options
* @return {String}
*/
declare function ms(value: number, options?: { long: boolean }): string;
/**
* Parse the given `value` and return milliseconds.
*
* @param {ms.StringValue} value
* @return {Number}
*/
declare function ms(value: ms.StringValue): number;
declare namespace ms {
// Unit, UnitAnyCase, and StringValue are backported from ms@3
// https://github.com/vercel/ms/blob/8b5923d1d86c84a9f6aba8022d416dcf2361aa8d/src/index.ts
type Unit =
| "Years"
| "Year"
| "Yrs"
| "Yr"
| "Y"
| "Weeks"
| "Week"
| "W"
| "Days"
| "Day"
| "D"
| "Hours"
| "Hour"
| "Hrs"
| "Hr"
| "H"
| "Minutes"
| "Minute"
| "Mins"
| "Min"
| "M"
| "Seconds"
| "Second"
| "Secs"
| "Sec"
| "s"
| "Milliseconds"
| "Millisecond"
| "Msecs"
| "Msec"
| "Ms";
type UnitAnyCase = Unit | Uppercase<Unit> | Lowercase<Unit>;
type StringValue =
| `${number}`
| `${number}${UnitAnyCase}`
| `${number} ${UnitAnyCase}`;
}
export = ms;
+26
View File
@@ -0,0 +1,26 @@
{
"name": "@types/ms",
"version": "2.1.0",
"description": "TypeScript definitions for ms",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/ms",
"license": "MIT",
"contributors": [
{
"name": "Zhiyuan Wang",
"githubUsername": "danny8002",
"url": "https://github.com/danny8002"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/ms"
},
"scripts": {},
"dependencies": {},
"peerDependencies": {},
"typesPublisherContentHash": "2c8651ce1714fdc6bcbc0f262c93a790f1d127fb1c2dc8edbb583decef56fd39",
"typeScriptVersion": "5.0"
}
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
+122
View File
@@ -0,0 +1,122 @@
# Installation
> `npm install --save @types/unist`
# Summary
This package contains type definitions for unist (https://github.com/syntax-tree/unist).
# Details
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/unist/v2.
## [index.d.ts](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/unist/v2/index.d.ts)
````ts
/**
* 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<TData extends object = Data> {
/**
* The variant of a node.
*/
type: string;
/**
* Information from the ecosystem.
*/
data?: TData | 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;
}
/**
* 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<ChildNode extends Node<object> = Node, TData extends object = NodeData<ChildNode>>
extends Node<TData>
{
/**
* List representing the children of a node.
*/
children: ChildNode[];
}
/**
* Nodes containing a value.
*
* @typeParam Value Specific value type of {@link Literal.value} such as `string` for `Text` node
*/
export interface Literal<Value = unknown, TData extends object = Data> extends Node<TData> {
value: Value;
}
````
### Additional Details
* Last updated: Thu, 15 Aug 2024 02:18:53 GMT
* Dependencies: 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), [Ben Moon](https://github.com/GuiltyDolphin), and [JounQin](https://github.com/JounQin).
+103
View File
@@ -0,0 +1,103 @@
/**
* 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<TData extends object = Data> {
/**
* The variant of a node.
*/
type: string;
/**
* Information from the ecosystem.
*/
data?: TData | 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;
}
/**
* 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<ChildNode extends Node<object> = Node, TData extends object = NodeData<ChildNode>>
extends Node<TData>
{
/**
* List representing the children of a node.
*/
children: ChildNode[];
}
/**
* Nodes containing a value.
*
* @typeParam Value Specific value type of {@link Literal.value} such as `string` for `Text` node
*/
export interface Literal<Value = unknown, TData extends object = Data> extends Node<TData> {
value: Value;
}
+55
View File
@@ -0,0 +1,55 @@
{
"name": "@types/unist",
"version": "2.0.11",
"description": "TypeScript definitions for unist",
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/unist",
"license": "MIT",
"contributors": [
{
"name": "bizen241",
"githubUsername": "bizen241",
"url": "https://github.com/bizen241"
},
{
"name": "Jun Lu",
"githubUsername": "lujun2",
"url": "https://github.com/lujun2"
},
{
"name": "Hernan Rajchert",
"githubUsername": "hrajchert",
"url": "https://github.com/hrajchert"
},
{
"name": "Titus Wormer",
"githubUsername": "wooorm",
"url": "https://github.com/wooorm"
},
{
"name": "Junyoung Choi",
"githubUsername": "rokt33r",
"url": "https://github.com/rokt33r"
},
{
"name": "Ben Moon",
"githubUsername": "GuiltyDolphin",
"url": "https://github.com/GuiltyDolphin"
},
{
"name": "JounQin",
"githubUsername": "JounQin",
"url": "https://github.com/JounQin"
}
],
"main": "",
"types": "index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git",
"directory": "types/unist"
},
"scripts": {},
"dependencies": {},
"typesPublisherContentHash": "6e36525a6db49ae5517fe0751796ca8f6c65099098415046d4f1ad6c2ef1a33c",
"typeScriptVersion": "4.8"
}