1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
tests/cases/compiler/file1.js(2,7): error TS2322: Type 'C' is not assignable to type 'ClassComponent<any>'.
tests/cases/compiler/tile1.ts(2,30): error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle<Attrs, State>'.
tests/cases/compiler/tile1.ts(6,81): error TS2744: Type parameter defaults can only reference previously declared type parameters.
tests/cases/compiler/tile1.ts(11,40): error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle<Attrs, State>'.
tests/cases/compiler/tile1.ts(21,2): error TS2416: Property 'view' in type 'C' is not assignable to the same property in base type 'ClassComponent<MyAttrs>'.
Type '(v: Vnode<MyAttrs, Lifecycle<MyAttrs, any>>) => number' is not assignable to type '(vnode: Vnode<MyAttrs, this>) => number'.
Types of parameters 'v' and 'vnode' are incompatible.
Type 'Vnode<MyAttrs, this>' is not assignable to type 'Vnode<MyAttrs, Lifecycle<MyAttrs, any>>'.
Type 'this' is not assignable to type 'Lifecycle<MyAttrs, any>'.
Type 'C' is not assignable to type 'Lifecycle<MyAttrs, any>'.
Index signature for type 'number' is missing in type 'C'.
tests/cases/compiler/tile1.ts(24,7): error TS2322: Type 'C' is not assignable to type 'ClassComponent<any>'.
Index signature for type 'number' is missing in type 'C'.
==== tests/cases/compiler/tile1.ts (5 errors) ====
interface Lifecycle<Attrs, State> {
oninit?(vnode: Vnode<Attrs, State>): number;
~~~~~
!!! error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle<Attrs, State>'.
!!! related TS2208 tests/cases/compiler/tile1.ts:1:28: This type parameter might need an `extends Lifecycle<Attrs, State>` constraint.
[_: number]: any;
}
interface Vnode<Attrs, State extends Lifecycle<Attrs, State> = Lifecycle<Attrs, State>> {
~~~~~
!!! error TS2744: Type parameter defaults can only reference previously declared type parameters.
tag: Component<Attrs, State>;
}
interface Component<Attrs, State> {
view(this: State, vnode: Vnode<Attrs, State>): number;
~~~~~
!!! error TS2344: Type 'State' does not satisfy the constraint 'Lifecycle<Attrs, State>'.
!!! related TS2208 tests/cases/compiler/tile1.ts:10:28: This type parameter might need an `extends Lifecycle<Attrs, State>` constraint.
}
interface ClassComponent<A> extends Lifecycle<A, ClassComponent<A>> {
oninit?(vnode: Vnode<A, this>): number;
view(vnode: Vnode<A, this>): number;
}
interface MyAttrs { id: number }
class C implements ClassComponent<MyAttrs> {
view(v: Vnode<MyAttrs>) { return 0; }
~~~~
!!! error TS2416: Property 'view' in type 'C' is not assignable to the same property in base type 'ClassComponent<MyAttrs>'.
!!! error TS2416: Type '(v: Vnode<MyAttrs, Lifecycle<MyAttrs, any>>) => number' is not assignable to type '(vnode: Vnode<MyAttrs, this>) => number'.
!!! error TS2416: Types of parameters 'v' and 'vnode' are incompatible.
!!! error TS2416: Type 'Vnode<MyAttrs, this>' is not assignable to type 'Vnode<MyAttrs, Lifecycle<MyAttrs, any>>'.
!!! error TS2416: Type 'this' is not assignable to type 'Lifecycle<MyAttrs, any>'.
!!! error TS2416: Type 'C' is not assignable to type 'Lifecycle<MyAttrs, any>'.
!!! error TS2416: Index signature for type 'number' is missing in type 'C'.
}
const test8: ClassComponent<any> = new C();
~~~~~
!!! error TS2322: Type 'C' is not assignable to type 'ClassComponent<any>'.
!!! error TS2322: Index signature for type 'number' is missing in type 'C'.
==== tests/cases/compiler/file1.js (1 errors) ====
/** @type {ClassComponent<any>} */
const test9 = new C();
~~~~~
!!! error TS2322: Type 'C' is not assignable to type 'ClassComponent<any>'.
|