Skip to content

Commit 304e568

Browse files
committed
chore(web): update type definitions
1 parent 9d62f17 commit 304e568

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

lib/binding_web/web-tree-sitter.d.ts

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ declare module 'web-tree-sitter' {
8888
/**
8989
* A function that is called periodically during parsing to check
9090
* whether parsing should be cancelled. If the progress callback returns
91-
* `false`, then parsing will be cancelled. You can also use this to instrument
91+
* `true`, then parsing will be cancelled. You can also use this to instrument
9292
* parsing and check where the parser is at in the document. The progress callback
9393
* takes a single argument, which is a {@link ParseState} representing the current
9494
* state of the parser.
@@ -102,6 +102,8 @@ declare module 'web-tree-sitter' {
102102
export interface ParseState {
103103
/** The byte offset in the document that the parser is at. */
104104
currentOffset: number;
105+
/** Indicates whether the parser has encountered an error during parsing. */
106+
hasError: boolean;
105107
}
106108
/**
107109
* The latest ABI version that is supported by the current version of the
@@ -200,6 +202,11 @@ declare module 'web-tree-sitter' {
200202
/** Get the parser's current logger. */
201203
getLogger(): LogCallback | null;
202204
}
205+
class LanguageMetadata {
206+
readonly major_version: number;
207+
readonly minor_version: number;
208+
readonly patch_version: number;
209+
}
203210
/**
204211
* An opaque object that defines how to parse a particular language.
205212
* The code for each `Language` is generated by the Tree-sitter CLI.
@@ -220,9 +227,20 @@ declare module 'web-tree-sitter' {
220227
*/
221228
get name(): string | null;
222229
/**
230+
* @deprecated since version 0.25.0, use {@link Language#abiVersion} instead
223231
* Gets the version of the language.
224232
*/
225233
get version(): number;
234+
/**
235+
* Gets the ABI version of the language.
236+
*/
237+
get abiVersion(): number;
238+
/**
239+
* Get the metadata for this language. This information is generated by the
240+
* CLI, and relies on the language author providing the correct metadata in
241+
* the language's `tree-sitter.json` file.
242+
*/
243+
get metadata(): LanguageMetadata | null;
226244
/**
227245
* Gets the number of fields in the language.
228246
*/
@@ -847,19 +865,31 @@ declare module 'web-tree-sitter' {
847865
* types of steps, which correspond to the two legal values for
848866
* the `type` field:
849867
*
850-
* - `capture` - Steps with this type represent names
851-
* of captures. The `name` field is the name of the capture.
868+
* - `CapturePredicateStep` - Steps with this type represent names
869+
* of captures.
870+
*
871+
* - `StringPredicateStep` - Steps with this type represent literal
872+
* strings.
873+
*/
874+
export type PredicateStep = CapturePredicateStep | StringPredicateStep;
875+
/**
876+
* A step in a predicate that refers to a capture.
852877
*
853-
* - `string` - Steps with this type represent literal
854-
* strings. The `value` field is the string value.
878+
* The `name` field is the name of the capture.
855879
*/
856-
export type PredicateStep = {
880+
interface CapturePredicateStep {
857881
type: 'capture';
858882
name: string;
859-
} | {
883+
}
884+
/**
885+
* A step in a predicate that refers to a string.
886+
*
887+
* The `value` field is the string value.
888+
*/
889+
interface StringPredicateStep {
860890
type: 'string';
861891
value: string;
862-
};
892+
}
863893
export class Query {
864894
/** The names of the captures used in the query. */
865895
readonly captureNames: string[];

lib/binding_web/web-tree-sitter.d.ts.map

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"LANGUAGE_VERSION",
1414
"MIN_COMPATIBLE_VERSION",
1515
"Parser",
16+
"LanguageMetadata",
1617
"Language",
1718
"Tree",
1819
"Node",
@@ -25,6 +26,8 @@
2526
"QueryMatch",
2627
"CaptureQuantifier",
2728
"PredicateStep",
29+
"CapturePredicateStep",
30+
"StringPredicateStep",
2831
"Query",
2932
"LookaheadIterator"
3033
],
@@ -48,6 +51,6 @@
4851
null,
4952
null
5053
],
51-
"mappings": ";;;;;;mBASiBA,KAAKA;;;;;;;;;;mBAYLC,KAAKA;;;;;;;;;;;;;mBAiBLC,IAAIA;;;;;;;;;;;;;;;;;cA4CTC,aAAaA;;;;cAKbC,gBAAgBA;;;;;;cAOhBC,WAAWA;;;;;;;;;;;;kBC7ENC,YAAYA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAmCZC,UAAUA;;;;;;;;;;;;;YAqBhBC,gBAAgBA;;;;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