TypeScript
Last updated
Was this helpful?
Last updated
Was this helpful?
The library supports by the definitions in types/index.d.ts
file. The project is prepared to work without additional configuration. You can import types from the package besides other functions.
The web component definition should combine two parts:
An interface
, which extends HTMLElement
A map of descriptors of the Hybrids<E>
type (where generic type E
is the defined interface)
A counter component example can be written in TS with the following code:
The following types are the public API, and any change to those will follow semantic versioning of the library:
Hybrids<E>
type including Descriptor<E>
and Property<E>
interfaces
All declarations of the main exports of the library
For a deeper understanding, read the types/index.d.ts
source file.
The Hybrids<E>
type has built-in support for the and all of the rules. It also prevents defining properties not declared in the interface. All hybrids public APIs support generic type <E>
for providing the additional information from the defined interface, for example, html<E>
or define<E>(...)
. However, in most of the cases, it is not necessary to pass the generic type explicitly - TS calculates it from the Hybrids<E>
main type.