mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
45 lines
1.9 KiB
Plaintext
45 lines
1.9 KiB
Plaintext
BaseClass.ts(4,5): error TS2564: Property 'baseProperty' has no initializer and is not definitely assigned in the constructor.
|
|
FinalClass.ts(5,5): error TS2564: Property 'extendedClassProperty' has no initializer and is not definitely assigned in the constructor.
|
|
MixinClass.ts(9,9): error TS2564: Property 'mixinProperty' has no initializer and is not definitely assigned in the constructor.
|
|
|
|
|
|
==== BaseClass.ts (1 errors) ====
|
|
export type Constructor<T> = new (...args: any[]) => T;
|
|
|
|
export class MyBaseClass<T> {
|
|
baseProperty: string;
|
|
~~~~~~~~~~~~
|
|
!!! error TS2564: Property 'baseProperty' has no initializer and is not definitely assigned in the constructor.
|
|
constructor(value: T) {}
|
|
}
|
|
==== MixinClass.ts (1 errors) ====
|
|
import { Constructor, MyBaseClass } from './BaseClass';
|
|
|
|
export interface MyMixin {
|
|
mixinProperty: string;
|
|
}
|
|
|
|
export function MyMixin<T extends Constructor<MyBaseClass<any>>>(base: T): T & Constructor<MyMixin> {
|
|
return class extends base {
|
|
mixinProperty: string;
|
|
~~~~~~~~~~~~~
|
|
!!! error TS2564: Property 'mixinProperty' has no initializer and is not definitely assigned in the constructor.
|
|
}
|
|
}
|
|
==== FinalClass.ts (1 errors) ====
|
|
import { MyBaseClass } from './BaseClass';
|
|
import { MyMixin } from './MixinClass';
|
|
|
|
export class MyExtendedClass extends MyMixin(MyBaseClass)<string> {
|
|
extendedClassProperty: number;
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2564: Property 'extendedClassProperty' has no initializer and is not definitely assigned in the constructor.
|
|
}
|
|
==== Main.ts (0 errors) ====
|
|
import { MyExtendedClass } from './FinalClass';
|
|
import { MyMixin } from './MixinClass';
|
|
|
|
const myExtendedClass = new MyExtendedClass('string');
|
|
|
|
const AnotherMixedClass = MyMixin(MyExtendedClass);
|
|
|