Intrinsic elements
Intrinsic elements are looked up on the special interface JSX.IntrinsicElements
. By default, if this interface is not specified, then anything goes and intrinsic elements will not be type checked. However, if interface is present, then the name of the intrinsic element is looked up as a property on the JSX.IntrinsicElements
interface. For example:
declare namespace JSX { interface IntrinsicElements { foo: any } } <foo />; // ok <bar />; // error
In the above example, <foo />
will work fine but <bar />
will result in an error since it has not been specified on JSX.IntrinsicElements
.
Note: You can also specify a catch-all string indexer on
JSX.IntrinsicElements
as follows:ts declare namespace JSX { interface IntrinsicElements { [elemName: string]: any; } }
Please login to continue.