2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts (15 errors) ====
|
|
|
|
interface I {
|
|
|
|
id: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
class C implements I {
|
|
|
|
id: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
class D<T>{
|
|
|
|
source: T;
|
|
|
|
recurse: D<T>;
|
|
|
|
wrapped: D<D<T>>
|
|
|
|
}
|
|
|
|
|
|
|
|
function F(x: string): number { return 42; }
|
|
|
|
function F2(x: number): boolean { return x < 42; }
|
|
|
|
|
|
|
|
module M {
|
|
|
|
export class A {
|
|
|
|
name: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function F2(x: number): string { return x.toString(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
module N {
|
|
|
|
export class A {
|
|
|
|
id: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function F2(x: number): string { return x.toString(); }
|
|
|
|
}
|
|
|
|
|
|
|
|
var aNumber: number = 'this is a string';
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'string' is not assignable to type 'number'.
|
|
|
|
var aString: string = 9.9;
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'number' is not assignable to type 'string'.
|
|
|
|
var aDate: Date = 9.9;
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'number' is not assignable to type 'Date':
|
|
|
|
!!! Property 'toDateString' is missing in type 'Number'.
|
|
|
|
|
|
|
|
var aVoid: void = 9.9;
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'number' is not assignable to type 'void'.
|
|
|
|
|
|
|
|
var anInterface: I = new D();
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'D<{}>' is not assignable to type 'I':
|
|
|
|
!!! Property 'id' is missing in type 'D<{}>'.
|
|
|
|
var aClass: C = new D();
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'D<{}>' is not assignable to type 'C':
|
|
|
|
!!! Property 'id' is missing in type 'D<{}>'.
|
|
|
|
var aGenericClass: D<string> = new C();
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~~~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'C' is not assignable to type 'D<string>':
|
|
|
|
!!! Property 'source' is missing in type 'C'.
|
|
|
|
var anObjectLiteral: I = { id: 'a string' };
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~~~~~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type '{ id: string; }' is not assignable to type 'I':
|
|
|
|
!!! Types of property 'id' are incompatible:
|
|
|
|
!!! Type 'string' is not assignable to type 'number'.
|
|
|
|
var anOtherObjectLiteral: { id: string } = new C();
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~~~~~~~~~~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'C' is not assignable to type '{ id: string; }':
|
|
|
|
!!! Types of property 'id' are incompatible:
|
|
|
|
!!! Type 'number' is not assignable to type 'string'.
|
|
|
|
|
|
|
|
var aFunction: typeof F = F2;
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type '(x: number) => boolean' is not assignable to type '(x: string) => number':
|
|
|
|
!!! Types of parameters 'x' and 'x' are incompatible:
|
|
|
|
!!! Type 'number' is not assignable to type 'string'.
|
|
|
|
var anOtherFunction: (x: string) => number = F2;
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~~~~~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type '(x: number) => boolean' is not assignable to type '(x: string) => number':
|
|
|
|
!!! Types of parameters 'x' and 'x' are incompatible:
|
|
|
|
!!! Type 'number' is not assignable to type 'string'.
|
|
|
|
var aLambda: typeof F = (x) => 'a string';
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type '(x: string) => string' is not assignable to type '(x: string) => number':
|
|
|
|
!!! Type 'string' is not assignable to type 'number'.
|
|
|
|
|
|
|
|
var aModule: typeof M = N;
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'typeof N' is not assignable to type 'typeof M':
|
|
|
|
!!! Types of property 'A' are incompatible:
|
|
|
|
!!! Type 'typeof A' is not assignable to type 'typeof A':
|
|
|
|
!!! Type 'A' is not assignable to type 'A':
|
|
|
|
!!! Property 'name' is missing in type 'A'.
|
|
|
|
var aClassInModule: M.A = new N.A();
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~~~~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type 'A' is not assignable to type 'A':
|
|
|
|
!!! Property 'name' is missing in type 'A'.
|
|
|
|
var aFunctionInModule: typeof M.F2 = F2;
|
2014-07-19 02:30:06 +02:00
|
|
|
~~~~~~~~~~~~~~~~~
|
2014-07-13 01:04:16 +02:00
|
|
|
!!! Type '(x: number) => boolean' is not assignable to type '(x: number) => string':
|
|
|
|
!!! Type 'boolean' is not assignable to type 'string'.
|
|
|
|
|
|
|
|
|