chore(web): update type definitions

This commit is contained in:
Amaan Qureshi 2025-01-28 19:34:05 -05:00
parent 9d62f17bc4
commit 304e56850f
2 changed files with 42 additions and 9 deletions

View file

@ -88,7 +88,7 @@ declare module 'web-tree-sitter' {
/**
* A function that is called periodically during parsing to check
* whether parsing should be cancelled. If the progress callback returns
* `false`, then parsing will be cancelled. You can also use this to instrument
* `true`, then parsing will be cancelled. You can also use this to instrument
* parsing and check where the parser is at in the document. The progress callback
* takes a single argument, which is a {@link ParseState} representing the current
* state of the parser.
@ -102,6 +102,8 @@ declare module 'web-tree-sitter' {
export interface ParseState {
/** The byte offset in the document that the parser is at. */
currentOffset: number;
/** Indicates whether the parser has encountered an error during parsing. */
hasError: boolean;
}
/**
* The latest ABI version that is supported by the current version of the
@ -200,6 +202,11 @@ declare module 'web-tree-sitter' {
/** Get the parser's current logger. */
getLogger(): LogCallback | null;
}
class LanguageMetadata {
readonly major_version: number;
readonly minor_version: number;
readonly patch_version: number;
}
/**
* An opaque object that defines how to parse a particular language.
* The code for each `Language` is generated by the Tree-sitter CLI.
@ -220,9 +227,20 @@ declare module 'web-tree-sitter' {
*/
get name(): string | null;
/**
* @deprecated since version 0.25.0, use {@link Language#abiVersion} instead
* Gets the version of the language.
*/
get version(): number;
/**
* Gets the ABI version of the language.
*/
get abiVersion(): number;
/**
* Get the metadata for this language. This information is generated by the
* CLI, and relies on the language author providing the correct metadata in
* the language's `tree-sitter.json` file.
*/
get metadata(): LanguageMetadata | null;
/**
* Gets the number of fields in the language.
*/
@ -847,19 +865,31 @@ declare module 'web-tree-sitter' {
* types of steps, which correspond to the two legal values for
* the `type` field:
*
* - `capture` - Steps with this type represent names
* of captures. The `name` field is the name of the capture.
* - `CapturePredicateStep` - Steps with this type represent names
* of captures.
*
* - `string` - Steps with this type represent literal
* strings. The `value` field is the string value.
* - `StringPredicateStep` - Steps with this type represent literal
* strings.
*/
export type PredicateStep = {
export type PredicateStep = CapturePredicateStep | StringPredicateStep;
/**
* A step in a predicate that refers to a capture.
*
* The `name` field is the name of the capture.
*/
interface CapturePredicateStep {
type: 'capture';
name: string;
} | {
}
/**
* A step in a predicate that refers to a string.
*
* The `value` field is the string value.
*/
interface StringPredicateStep {
type: 'string';
value: string;
};
}
export class Query {
/** The names of the captures used in the query. */
readonly captureNames: string[];

View file

@ -13,6 +13,7 @@
"LANGUAGE_VERSION",
"MIN_COMPATIBLE_VERSION",
"Parser",
"LanguageMetadata",
"Language",
"Tree",
"Node",
@ -25,6 +26,8 @@
"QueryMatch",
"CaptureQuantifier",
"PredicateStep",
"CapturePredicateStep",
"StringPredicateStep",
"Query",
"LookaheadIterator"
],
@ -48,6 +51,6 @@
null,
null
],
"mappings": ";;;;;;mBASiBA,KAAKA;;;;;;;;;;mBAYLC,KAAKA;;;;;;;;;;;;;mBAiBLC,IAAIA;;;;;;;;;;;;;;;;;cA4CTC,aAAaA;;;;cAKbC,gBAAgBA;;;;;;cAOhBC,WAAWA;;;;;;;;;;;;kBC7ENC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAmCZC,UAAUA;;;;;;;;;;;;;YAqBhBC,gBAAgBA;;;;;YAMhBC,sBAAsBA;;;;;cAMpBC,MAAMA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCrENC,QAAQA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCcRC,IAAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cCrBJC,IAAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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