mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
136 lines
6.1 KiB
Plaintext
136 lines
6.1 KiB
Plaintext
enumAssignability.ts(9,1): error TS2322: Type 'F' is not assignable to type 'E'.
|
|
enumAssignability.ts(10,1): error TS2322: Type 'E' is not assignable to type 'F'.
|
|
enumAssignability.ts(11,1): error TS2322: Type '1' is not assignable to type 'E'.
|
|
enumAssignability.ts(12,1): error TS2322: Type '1' is not assignable to type 'F'.
|
|
enumAssignability.ts(20,9): error TS2564: Property 'foo' has no initializer and is not definitely assigned in the constructor.
|
|
enumAssignability.ts(29,9): error TS2322: Type 'E' is not assignable to type 'string'.
|
|
enumAssignability.ts(30,9): error TS2322: Type 'E' is not assignable to type 'boolean'.
|
|
enumAssignability.ts(31,9): error TS2322: Type 'E' is not assignable to type 'Date'.
|
|
enumAssignability.ts(33,9): error TS2322: Type 'E' is not assignable to type 'void'.
|
|
enumAssignability.ts(36,9): error TS2322: Type 'E' is not assignable to type '() => {}'.
|
|
enumAssignability.ts(37,9): error TS2322: Type 'E' is not assignable to type 'Function'.
|
|
enumAssignability.ts(38,9): error TS2322: Type 'E' is not assignable to type '(x: number) => string'.
|
|
enumAssignability.ts(39,5): error TS2322: Type 'E' is not assignable to type 'C'.
|
|
enumAssignability.ts(40,5): error TS2322: Type 'E' is not assignable to type 'I'.
|
|
enumAssignability.ts(41,9): error TS2322: Type 'E' is not assignable to type 'number[]'.
|
|
enumAssignability.ts(42,9): error TS2322: Type 'E' is not assignable to type '{ foo: string; }'.
|
|
enumAssignability.ts(43,9): error TS2322: Type 'E' is not assignable to type '<T>(x: T) => T'.
|
|
enumAssignability.ts(45,9): error TS2322: Type 'E' is not assignable to type 'String'.
|
|
enumAssignability.ts(48,9): error TS2322: Type 'E' is not assignable to type 'T'.
|
|
'T' could be instantiated with an arbitrary type which could be unrelated to 'E'.
|
|
enumAssignability.ts(49,9): error TS2322: Type 'E' is not assignable to type 'U'.
|
|
'U' could be instantiated with an arbitrary type which could be unrelated to 'E'.
|
|
enumAssignability.ts(50,9): error TS2322: Type 'E' is not assignable to type 'V'.
|
|
'V' could be instantiated with an arbitrary type which could be unrelated to 'E'.
|
|
enumAssignability.ts(51,13): error TS2322: Type 'E' is not assignable to type 'A'.
|
|
'E' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype of constraint 'Number'.
|
|
enumAssignability.ts(52,13): error TS2322: Type 'E' is not assignable to type 'B'.
|
|
'E' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint 'E'.
|
|
|
|
|
|
==== enumAssignability.ts (23 errors) ====
|
|
// enums assignable to number, any, Object, errors unless otherwise noted
|
|
|
|
enum E { A }
|
|
enum F { B }
|
|
|
|
var e = E.A;
|
|
var f = F.B;
|
|
|
|
e = f;
|
|
~
|
|
!!! error TS2322: Type 'F' is not assignable to type 'E'.
|
|
f = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'F'.
|
|
e = 1; // ok
|
|
~
|
|
!!! error TS2322: Type '1' is not assignable to type 'E'.
|
|
f = 1; // ok
|
|
~
|
|
!!! error TS2322: Type '1' is not assignable to type 'F'.
|
|
var x: number = e; // ok
|
|
x = f; // ok
|
|
|
|
namespace Others {
|
|
var a: any = e; // ok
|
|
|
|
class C {
|
|
foo: string;
|
|
~~~
|
|
!!! error TS2564: Property 'foo' has no initializer and is not definitely assigned in the constructor.
|
|
}
|
|
var ac: C;
|
|
interface I {
|
|
foo: string;
|
|
}
|
|
var ai: I;
|
|
|
|
var b: number = e; // ok
|
|
var c: string = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'string'.
|
|
var d: boolean = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'boolean'.
|
|
var ee: Date = e;
|
|
~~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'Date'.
|
|
var f: any = e; // ok
|
|
var g: void = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'void'.
|
|
var h: Object = e;
|
|
var i: {} = e;
|
|
var j: () => {} = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type '() => {}'.
|
|
var k: Function = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'Function'.
|
|
var l: (x: number) => string = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type '(x: number) => string'.
|
|
ac = e;
|
|
~~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'C'.
|
|
ai = e;
|
|
~~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'I'.
|
|
var m: number[] = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'number[]'.
|
|
var n: { foo: string } = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type '{ foo: string; }'.
|
|
var o: <T>(x: T) => T = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type '<T>(x: T) => T'.
|
|
var p: Number = e;
|
|
var q: String = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'String'.
|
|
|
|
function foo<T, U extends T, V extends Date, A extends Number, B extends E>(x: T, y: U, z: V) {
|
|
x = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'T'.
|
|
!!! error TS2322: 'T' could be instantiated with an arbitrary type which could be unrelated to 'E'.
|
|
y = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'U'.
|
|
!!! error TS2322: 'U' could be instantiated with an arbitrary type which could be unrelated to 'E'.
|
|
z = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'V'.
|
|
!!! error TS2322: 'V' could be instantiated with an arbitrary type which could be unrelated to 'E'.
|
|
var a: A = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'A'.
|
|
!!! error TS2322: 'E' is assignable to the constraint of type 'A', but 'A' could be instantiated with a different subtype of constraint 'Number'.
|
|
var b: B = e;
|
|
~
|
|
!!! error TS2322: Type 'E' is not assignable to type 'B'.
|
|
!!! error TS2322: 'E' is assignable to the constraint of type 'B', but 'B' could be instantiated with a different subtype of constraint 'E'.
|
|
}
|
|
} |