49 lines
No EOL
1.1 KiB
Text
49 lines
No EOL
1.1 KiB
Text
==== tests/cases/conformance/types/primitives/void/invalidVoidValues.ts (11 errors) ====
|
|
var x: void;
|
|
x = 1;
|
|
~
|
|
!!! Type 'number' is not assignable to type 'void'.
|
|
x = '';
|
|
~
|
|
!!! Type 'string' is not assignable to type 'void'.
|
|
x = true;
|
|
~
|
|
!!! Type 'boolean' is not assignable to type 'void'.
|
|
|
|
enum E { A }
|
|
x = E;
|
|
~
|
|
!!! Type 'typeof E' is not assignable to type 'void'.
|
|
x = E.A;
|
|
~
|
|
!!! Type 'E' is not assignable to type 'void'.
|
|
|
|
class C { foo: string }
|
|
var a: C;
|
|
x = a;
|
|
~
|
|
!!! Type 'C' is not assignable to type 'void'.
|
|
|
|
interface I { foo: string }
|
|
var b: I;
|
|
x = b;
|
|
~
|
|
!!! Type 'I' is not assignable to type 'void'.
|
|
|
|
x = { f() {} }
|
|
~
|
|
!!! Type '{ f: () => void; }' is not assignable to type 'void'.
|
|
|
|
module M { export var x = 1; }
|
|
x = M;
|
|
~
|
|
!!! Type 'typeof M' is not assignable to type 'void'.
|
|
|
|
function f<T>(a: T) {
|
|
x = a;
|
|
~
|
|
!!! Type 'T' is not assignable to type 'void'.
|
|
}
|
|
x = f;
|
|
~
|
|
!!! Type '<T>(a: T) => void' is not assignable to type 'void'. |