I'm trying to get running Typescript with Immutable 3.8.1.
import { Record } from "immutable";
class Person extends Record({
name: "viktor" as string,
}) {
getName() {
return this.name;
}
}
const person = new Person({ name: "petko" });
console.log(person.getName());
this code produces the following error:
Property 'name' does not exist on type 'Person'.
5 | }) {
6 | getName() {
> 7 | return this.name;
| ^^^^
8 | }
9 | }
but it does compile and run. However, when I try to add name: string; just over the getName declaration (in the class body), the error goes away, but getName() returns undefined every time. What I'm doing wrong?