Typescript complains Property does not exist on type 'JSX.IntrinsicElements' when using React.createClass?
Your component must start with a capital letter I
instead of small letter i
otherwise TypeScript would yell. Changing item
to Item
should fix it:
var Item = React.createClass({
render: function() {
return (<div>hello world</div>)
}
});
export default class ItemList extends Component<any, any> {
render() {
return (<Item />)
}
}
That is because your item
component's name does not start with a capital letter, causing Typescript to complain. Replacing item
with Item
could solve this problem.
You can declare your custom element type like this:
import * as React from 'react'
declare global {
namespace JSX {
interface IntrinsicElements {
item: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement>;
}
}
}