Type Script Notes for Professionals: typed superset of JavaScript by Chahdi Othmane

Type Script Notes for Professionals: typed superset of JavaScript by Chahdi Othmane

Author:Chahdi, Othmane [Chahdi, Othmane]
Language: eng
Format: epub, azw3, mobi
Publisher: UNKNOWN
Published: 2021-07-28T00:00:00+00:00


Section 9.5: Add functions or properties to an existing interface

Let's suppose we have a reference to the JQuery type definition and we want to extend it to have additional functions from a plugin we included and which doesn't have an official type definition. We can easily extend it by declaring functions added by plugin in a separate interface declaration with the same JQuery name:

interface JQuery {

pluginFunctionThatDoesNothing(): void ;

// create chainable function

manipulateDOM( HTMLElement): JQuery; }

The compiler will merge all declarations with the same name into one - see declaration merging for more details.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.