Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- abstract class AbstractEvent<T> {
- public constructor(data: T) {
- for (const key in data) {
- (this as any)[key] = data[key];
- }
- }
- }
- class PackCreatedEvent extends AbstractEvent<PackCreatedEvent> {
- public readonly id: string;
- public readonly title: string;
- }
- const packCreatedEvent1 = new PackCreatedEvent({
- id: 'x',
- title: 'y',
- });
- const packCreatedEvent2 = new PackCreatedEvent({
- id: 'x',
- title: 'y',
- // Causes error as desired
- foo: 'test',
- });
Advertisement
Add Comment
Please, Sign In to add comment