Typescript: lib.dom.d.ts Document interface missing createNSResolver method.

Created on 19 Jan 2019  ·  7Comments  ·  Source: microsoft/TypeScript


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

lib.d.ts In Discussion Suggestion help wanted

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.

All 7 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Antony-Jones picture Antony-Jones  ·  3Comments

fwanicka picture fwanicka  ·  3Comments

zhuravlikjb picture zhuravlikjb  ·  3Comments

dlaberge picture dlaberge  ·  3Comments

DanielRosenwasser picture DanielRosenwasser  ·  3Comments