TypeScript Version: 3.3.0-dev.20190119
Search Terms: XPathEvaluator, Document, lib.dom.d.ts, createNSResolver
Code
document.createNSResolver(document);
Expected behavior:
Document should have the method createNSResolver.
Actually, according to w3c Document interface should extend XPathEvaluator interface (which has 3 methods: createExpression, createNSResolver and evaluate). Right now lib.dom.d.ts Document interface contains only evaluate method, the other two are missing.
"The evaluation of XPath expressions is provided by XPathEvaluator. In a DOM implementation which supports the XPath 3.0 feature, as described above, the XPathEvaluator interface will be implemented on the same object which implements the Document interface"
https://www.w3.org/TR/DOM-Level-3-XPath/xpath.html#XPathEvaluator
https://developer.mozilla.org/en-US/docs/Web/API/XPathEvaluator
Actual behavior:
Error: TS2339: Property 'createNSResolver' does not exist on type 'Document'.
Playground Link: https://www.typescriptlang.org/play/index.html#src=document.createNSResolver(document)%3B
Related Issues: #26437
PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.
I would love to work on this if it's still open (^_^)
@VisibleMarkov sure! Bonus points if you could implement is as a mixin, so it would be obvious that interface Document extends XPathEvaluator (I got totally lost in the codebase on my first attempt to do this). But even adding the missing methods signatures to the Document should do the job.
Thanks for the tip and the heads up. Will got on it ASAP (^_^)
Note that the old XPath spec doesn't have Web IDL but an older IDL syntax, maybe this wiki document would help.
@saschanaz, should I replace the current older syntax with the newer Web IDL syntax?
@VisibleMarkov, I updated the aforementioned wiki document so that it can be directly added to idlSources.json in TSJS-lib-generator. So now there should be no need to manually write anything.
Most helpful comment
@VisibleMarkov, I updated the aforementioned wiki document so that it can be directly added to idlSources.json in TSJS-lib-generator. So now there should be no need to manually write anything.