`dataclass` is like a data class from kotlin
npm install @jeemyeong/dataclassdataclass is like a data class from kotlin
- Written in TypeScript.
``sh`
$ npm i @jeemyeong/dataclass
typescript
class Person {
name!: string;
language: string | null = null;
public constructor(initializer: Initializer) {
Object.assign(this, initializer);
}
}const p1 = new Person({
name: "Leo"
}); // OK
const p2 = new Person({
name: "Leo",
language: "Korean",
}); // OK
const p3 = new Person({
name: "Leo",
age: 30 // error
});
``