'How do I extend a class definition that's missing types from DefinitelyTyped?
I want to use the Driver
instance method setNetworkConditions
from selenium-webdriver
, which is available in the source.
DefinitelyTyped is currently missing the types for this function. In fact, all it has is this:
export class Driver extends webdriver.WebDriver {
/**
* Creates a new session with the ChromeDriver.
*
* @param {(Capabilities|Options)=} opt_config The configuration options.
* @param {(remote.DriverService|http.Executor)=} opt_serviceExecutor Either
* a DriverService to use for the remote end, or a preconfigured executor
* for an externally managed endpoint. If neither is provided, the
* {@linkplain ##getDefaultService default service} will be used by
* default.
* @return {!Driver} A new driver instance.
*/
static createSession(
opt_config?: Options|webdriver.CreateSessionCapabilities,
opt_service?: remote.DriverService|http.Executor): Driver;
}
I want to extend this definition within my ambient.d.ts
file, which I have successfully used for projects that do not have any TS definitions at all.
Now, how go about doing this? I have tried adding this:
declare module 'selenium-webdriver/chrome' {
class Driver {
setNetworkConditions(spec: {});
}
}
But as soon as I add this, all other function type definitions from the Driver
class that it inherits from webdriver.WebDriver
appear as missing.
I have seen this question but it does not seem to match the use case of extending existing definitions.
How could I merge the definitions, or extend them, without having to copy-paste the DefinitelyTyped definitions for webdriver.WebDriver
?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|