TypeScript/tests/baselines/reference/everyTypeWithAnnotationAndInvalidInitializer.errors.txt

104 lines
3.6 KiB
Plaintext

==== 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';
~~~~~~~
!!! Type 'string' is not assignable to type 'number'.
var aString: string = 9.9;
~~~~~~~
!!! Type 'number' is not assignable to type 'string'.
var aDate: Date = 9.9;
~~~~~
!!! Type 'number' is not assignable to type 'Date':
!!! Property 'toDateString' is missing in type 'Number'.
var aVoid: void = 9.9;
~~~~~
!!! Type 'number' is not assignable to type 'void'.
var anInterface: I = new D();
~~~~~~~~~~~
!!! Type 'D<{}>' is not assignable to type 'I':
!!! Property 'id' is missing in type 'D<{}>'.
var aClass: C = new D();
~~~~~~
!!! Type 'D<{}>' is not assignable to type 'C':
!!! Property 'id' is missing in type 'D<{}>'.
var aGenericClass: D<string> = new C();
~~~~~~~~~~~~~
!!! Type 'C' is not assignable to type 'D<string>':
!!! Property 'source' is missing in type 'C'.
var anObjectLiteral: I = { id: 'a string' };
~~~~~~~~~~~~~~~
!!! 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();
~~~~~~~~~~~~~~~~~~~~
!!! 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;
~~~~~~~~~
!!! 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;
~~~~~~~~~~~~~~~
!!! 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';
~~~~~~~
!!! 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;
~~~~~~~
!!! 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();
~~~~~~~~~~~~~~
!!! Type 'A' is not assignable to type 'A':
!!! Property 'name' is missing in type 'A'.
var aFunctionInModule: typeof M.F2 = F2;
~~~~~~~~~~~~~~~~~
!!! Type '(x: number) => boolean' is not assignable to type '(x: number) => string':
!!! Type 'boolean' is not assignable to type 'string'.