Closed sdolski closed 3 years ago
I have made some further analysis.
The problem might be the static modifiers in the class JSONPathClass
of the jsonpath.d.ts
.
By removing those static modifiers the cache property and helper methods will become available.
Suggest taking a look at #113 . Not in a position to investigate myself, but PRs welcome.
I have seen #113. I am currently not using the sandbox. So I am not facing that issue.
My problem is that those, above mentioned helper methods are not accessible at all with typescript. I have delivered a small PR #151 to make them accessible
Ok, sorry, not looking carefully here.
Can you provide a source showing why this works? I would think static could be exported. Is it because of how the class is being part of an intersection or something?
Of course exporting static in general is not a problem. As well as the intersection. Exporting types, classes, object in the typescript declaration file is all fine.
But a static function need to be accessed in a static manner. ==> JSONPathClass.toPathArray(jsonPath)
In our case we are defining the type of JSONPath, which is a function exported by jsonpath.js. And because this is a function and not a class, we can not access the functions in a static manner.
But what we can do is, to declare that the exported JSONPath has additional functions (toPathArray(), toPathString(),....) as well as additional properties (cache). This is what we are trying to do with the JSONPathClass
. But because we are not exporting a class here, it does only work without the static modified.
Hope that helps for clarification
Fixed by #151 . Released as part of v5.0.6. Thanks for the report!
I am working with typescript and facing an issue by trying to use the following property and methods:
When accessing those property or methods I am getting the following errors:
Property 'toPathArray' does not exist on type 'JSONPathType'.ts(2339)
My guess is that the typescript declaration file
jsonpath.d.ts
is not correct.