1
1
import type { JsonNode } from "../json/jsonast.d.ts" ;
2
- import type { JrefNode } from "../jref/jref-ast.d.ts" ;
2
+ import type { JrefNode , JrefJrefNode } from "../jref/jref-ast.d.ts" ;
3
3
import type { UriSchemePlugin } from "./uri-schemes/uri-scheme-plugin.d.ts" ;
4
4
import type { DocumentNode , MediaTypePlugin } from "./media-types/media-type-plugin.d.ts" ;
5
5
import type { jsonObjectHas , jsonObjectKeys , jsonValue } from "../json/jsonast-util.js" ;
@@ -11,7 +11,8 @@ export type GetOptions = {
11
11
referencedFrom ?: string ;
12
12
} ;
13
13
14
- export class Hyperjump < T extends JrefNode = JrefNode > {
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ export class Hyperjump < T extends JrefNode < any > = JrefJrefNode > {
15
16
constructor ( config ?: HyperjumpConfig ) ;
16
17
17
18
/**
@@ -29,7 +30,7 @@ export class Hyperjump<T extends JrefNode = JrefNode> {
29
30
* @throws {@link RetrievalError }
30
31
* @throws {@link json.JsonPointerError }
31
32
*/
32
- get : ( uri : string , options ?: GetOptions ) => Promise < JsonNode < T > > ;
33
+ get : ( uri : string , options ?: GetOptions ) => Promise < T & JsonNode < T > > ;
33
34
34
35
/**
35
36
* Add support for a
@@ -93,27 +94,27 @@ export class Hyperjump<T extends JrefNode = JrefNode> {
93
94
* This is like indexing into an object or array. It will follow any
94
95
* references it encounters so it always returns a JSON compatible value.
95
96
*/
96
- step : ( key : string , node : JsonNode < T > ) => Promise < JsonNode < T > > ;
97
+ step : ( key : string , node : JsonNode < T > ) => Promise < T & JsonNode < T > > ;
97
98
98
99
/**
99
100
* Iterate over an array node. It will follow any references it encounters so
100
101
* it always yields JSON compatible values.
101
102
*/
102
- iter : ( node : JsonNode < T > ) => AsyncGenerator < JsonNode < T > , void , unknown > ;
103
+ iter : ( node : JsonNode < T > ) => AsyncGenerator < T & JsonNode < T > , void , unknown > ;
103
104
104
105
keys : typeof jsonObjectKeys ;
105
106
106
107
/**
107
108
* Iterate over the values of an object. It will follow any references it
108
109
* encounters so it always yields JSON compatible values.
109
110
*/
110
- values : ( node : JsonNode < T > ) => AsyncGenerator < JsonNode < T > , void , unknown > ;
111
+ values : ( node : JsonNode < T > ) => AsyncGenerator < T & JsonNode < T > , void , unknown > ;
111
112
112
113
/**
113
114
* Iterate over key/value pairs of an object. It will follow any references it
114
115
* encounters so it always yields JSON compatible values.
115
116
*/
116
- entries : ( node : JsonNode < T > ) => AsyncGenerator < [ string , JsonNode < T > ] , void , unknown > ;
117
+ entries : ( node : JsonNode < T > ) => AsyncGenerator < [ string , T & JsonNode < T > ] , void , unknown > ;
117
118
}
118
119
119
120
export class RetrievalError extends Error {
0 commit comments