I can't figure out how to define properly the namespaceResolver function in TypeScript. I have the following resolver function:
(prefix: string): string => {
if (prefix === "wms") {
return "http://www.opengis.net/wms";
} else {
return null;
}
But the compiler complains that:
TS2345: Argument of type '(prefix: string) => string' is not assignable to parameter of type 'XPathNSResolver'. Property 'lookupNamespaceURI' is missing in type '(prefix: string) => string'.
If I check the implementation in lib.dom.d.ts, the lookupNaemspaceURI's return value is string too. So I have no idea how should I fix this.
lib.dom.d.ts:
interface XPathNSResolver {
lookupNamespaceURI(prefix: string): string;
}
EDIT
Here is the whole code:
doc.evaluate("/wms:WMS_Capabilities/wms:Service/wms:Name", doc, (prefix: string): string => {
if (prefix === "wms") {
return "http://www.opengis.net/wms";
} else {
return null;
}
}, XPathResult.STRING_TYPE, null);