I am fairly new to TypeScript, and have been handed an ES6 based react project, and would like to Migrate over to TypeScript for a more integrated state. Anything following a (this.) seems to break with error (Property "foo" does not exist on Type "bar")
import * as React from 'react';
import { Component } from 'react';
class Clock extends Component {
constructor(props: {}) {
super(props);
this.state = {
date: new Date()
};
}
componentDidMount() {
this.timerId = setInterval(
() => this.tick(), 500
);
}
componentWillUnmount() {
clearInterval(this.timerId);
}
tick() {
this.setState({
date: new Date()
});
}
render() {
const options = { hour24: false };
return (
<div className="clockDesign">{this.state.date.toLocaleString('en-US', options)}</div>
);
}
}
export default Clock;
My question is this. How would I go about converting the inline definitions to types within my class statement?