class MyComponent extends Component<Props,States> {
constructor(props: Props) {
super(props);
this.spells = 'abc'
}
}
javascript였다면 spells를 추가하는게 문제가 안되는데, typescript에서는 내 맘대로 프로퍼티를 추가하면 안된다. MyComponent라는 타입에다가 먼저 spells라는 프로퍼티가 들어갈것이라고 알려줘야한다.
class MyComponent extends Component<Props,States> {
constructor(props: Props) {
super(props);
this.spells = 'abc'
}
}