|
|
|
|
|
by nicolodavis
2173 days ago
|
|
That's correct. You have to insert validation code at all the entry points, which was the case for me. Moving to Rust doesn't eliminate validation altogether, but you don't have to do any type related validation which is nice. |
|
https://codesandbox.io/s/is849
edit: complete code
```typescript
class Person { id: number; name: string; yearOfBirth: number;
}class Dog { id: number; name: string; yearOfBirth: number;
}const buzz: Person = new Person(1, `Buzz`, 1987);
const airbud: Dog = buzz;
console.log(`Buzz is ${buzz.getAge()} years old.`);
console.log(`Airbud is ${airbud.getAge()} years old in human years.`);
```