@@ -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 [ ] ;
0 commit comments