What's Component<any, any> in Typescripted React? Props and state. I mean, you knew that, but here's some confirmation. Took me a while for my desire for confirmation and ability to google successfully to match up.

From github.io:

Sometimes youโ€™ll see definitions likeย class MyComponent extends React.Component<{}, {}>. This means that this component doesnโ€™t use props or stateโ€”they must be empty.ย class MyComponent extends React.Component<any, any>ย says that you can pass anything for props and state and it will do no type checking.

What a weird mishmash of C# and JavaScript this TypeScript is. I mean, I like it, but it feels like an incomplete language that allows shortcuts borrowed directly from two different languages. I'm not saying I dislike it, but TypeScript is a strange pastiche of programming paradigms.

Labels: , ,