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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(34,5): error TS2322: Type '"this is a string"' is not assignable to type 'number'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(35,5): error TS2322: Type '9.9' is not assignable to type 'string'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(36,5): error TS2322: Type '9.9' is not assignable to type 'Date'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(38,5): error TS2322: Type '9.9' is not assignable to type 'void'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(40,5): error TS2741: Property 'id' is missing in type 'D<{}>' but required in type 'I'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(41,5): error TS2741: Property 'id' is missing in type 'D<{}>' but required in type 'C'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(42,5): error TS2739: Type 'C' is missing the following properties from type 'D<string>': source, recurse, wrapped
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(43,28): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(44,5): error TS2322: Type 'C' is not assignable to type '{ id: string; }'.
Types of property 'id' are incompatible.
Type 'number' is not assignable to type 'string'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(46,5): error TS2322: Type '(x: number) => boolean' is not assignable to type '(x: string) => number'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(47,5): error TS2322: Type '(x: number) => boolean' is not assignable to type '(x: string) => number'.
Types of parameters 'x' and 'x' are incompatible.
Type 'string' is not assignable to type 'number'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(48,32): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(50,5): error TS2322: Type 'typeof N' is not assignable to type 'typeof M'.
Types of property 'A' are incompatible.
Type 'typeof N.A' is not assignable to type 'typeof M.A'.
Property 'name' is missing in type 'A' but required in type 'A'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(51,5): error TS2322: Type 'N.A' is not assignable to type 'M.A'.
tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts(52,5): error TS2322: Type '(x: number) => boolean' is not assignable to type '(x: number) => string'.
Type 'boolean' is not assignable to type 'string'.
==== 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';
~~~~~~~
!!! error TS2322: Type '"this is a string"' is not assignable to type 'number'.
var aString: string = 9.9;
~~~~~~~
!!! error TS2322: Type '9.9' is not assignable to type 'string'.
var aDate: Date = 9.9;
~~~~~
!!! error TS2322: Type '9.9' is not assignable to type 'Date'.
var aVoid: void = 9.9;
~~~~~
!!! error TS2322: Type '9.9' is not assignable to type 'void'.
var anInterface: I = new D();
~~~~~~~~~~~
!!! error TS2741: Property 'id' is missing in type 'D<{}>' but required in type 'I'.
!!! related TS2728 tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts:2:5: 'id' is declared here.
var aClass: C = new D();
~~~~~~
!!! error TS2741: Property 'id' is missing in type 'D<{}>' but required in type 'C'.
!!! related TS2728 tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts:6:5: 'id' is declared here.
var aGenericClass: D<string> = new C();
~~~~~~~~~~~~~
!!! error TS2739: Type 'C' is missing the following properties from type 'D<string>': source, recurse, wrapped
var anObjectLiteral: I = { id: 'a string' };
~~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! related TS6500 tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts:2:5: The expected type comes from property 'id' which is declared here on type 'I'
var anOtherObjectLiteral: { id: string } = new C();
~~~~~~~~~~~~~~~~~~~~
!!! error TS2322: Type 'C' is not assignable to type '{ id: string; }'.
!!! error TS2322: Types of property 'id' are incompatible.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
var aFunction: typeof F = F2;
~~~~~~~~~
!!! error TS2322: Type '(x: number) => boolean' is not assignable to type '(x: string) => number'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var anOtherFunction: (x: string) => number = F2;
~~~~~~~~~~~~~~~
!!! error TS2322: Type '(x: number) => boolean' is not assignable to type '(x: string) => number'.
!!! error TS2322: Types of parameters 'x' and 'x' are incompatible.
!!! error TS2322: Type 'string' is not assignable to type 'number'.
var aLambda: typeof F = (x) => 'a string';
~~~~~~~~~~
!!! error TS2322: Type 'string' is not assignable to type 'number'.
!!! related TS6502 tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts:15:10: The expected type comes from the return type of this signature.
var aModule: typeof M = N;
~~~~~~~
!!! error TS2322: Type 'typeof N' is not assignable to type 'typeof M'.
!!! error TS2322: Types of property 'A' are incompatible.
!!! error TS2322: Type 'typeof N.A' is not assignable to type 'typeof M.A'.
!!! error TS2322: Property 'name' is missing in type 'A' but required in type 'A'.
!!! related TS2728 tests/cases/conformance/statements/VariableStatements/everyTypeWithAnnotationAndInvalidInitializer.ts:20:9: 'name' is declared here.
var aClassInModule: M.A = new N.A();
~~~~~~~~~~~~~~
!!! error TS2322: Type 'N.A' is not assignable to type 'M.A'.
var aFunctionInModule: typeof M.F2 = F2;
~~~~~~~~~~~~~~~~~
!!! error TS2322: Type '(x: number) => boolean' is not assignable to type '(x: number) => string'.
!!! error TS2322: Type 'boolean' is not assignable to type 'string'.
|