2014-10-28 08:28:59 +01:00
tests/cases/compiler/incompatibleTypes.ts(5,7): error TS2420: Class 'C1' incorrectly implements interface 'IFoo1'.
Types of property 'p1' are incompatible.
Type '() => string' is not assignable to type '() => number'.
2014-09-12 22:35:07 +02:00
Type 'string' is not assignable to type 'number'.
2014-10-28 08:28:59 +01:00
tests/cases/compiler/incompatibleTypes.ts(15,7): error TS2420: Class 'C2' incorrectly implements interface 'IFoo2'.
Types of property 'p1' are incompatible.
Type '(n: number) => number' is not assignable to type '(s: string) => number'.
Types of parameters 'n' and 's' are incompatible.
2014-09-12 22:35:07 +02:00
Type 'number' is not assignable to type 'string'.
2014-10-28 08:28:59 +01:00
tests/cases/compiler/incompatibleTypes.ts(25,7): error TS2420: Class 'C3' incorrectly implements interface 'IFoo3'.
Types of property 'p1' are incompatible.
2014-09-12 22:35:07 +02:00
Type 'number' is not assignable to type 'string'.
2014-10-28 08:28:59 +01:00
tests/cases/compiler/incompatibleTypes.ts(33,7): error TS2420: Class 'C4' incorrectly implements interface 'IFoo4'.
Types of property 'p1' are incompatible.
Type '{ c: { b: string; }; d: string; }' is not assignable to type '{ a: { a: string; }; b: string; }'.
2014-09-12 22:35:07 +02:00
Property 'a' is missing in type '{ c: { b: string; }; d: string; }'.
tests/cases/compiler/incompatibleTypes.ts(42,5): error TS2345: Argument of type 'C1' is not assignable to parameter of type 'IFoo2'.
tests/cases/compiler/incompatibleTypes.ts(49,5): error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'.
Property 'c' is missing in type '{ e: number; f: number; }'.
2014-11-05 21:26:03 +01:00
tests/cases/compiler/incompatibleTypes.ts(66,5): error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'.
2014-09-12 22:35:07 +02:00
Property 'a' is missing in type '{ e: number; f: number; }'.
2014-11-05 21:26:03 +01:00
tests/cases/compiler/incompatibleTypes.ts(72,5): error TS2322: Type 'number' is not assignable to type '() => string'.
tests/cases/compiler/incompatibleTypes.ts(74,5): error TS2322: Type '(a: any) => number' is not assignable to type '() => any'.
2014-09-12 22:35:07 +02:00
2014-07-13 01:04:16 +02:00
==== tests/cases/compiler/incompatibleTypes.ts (9 errors) ====
interface IFoo1 {
p1(): number;
}
class C1 implements IFoo1 { // incompatible on the return type
~~
2014-10-28 08:28:59 +01:00
!!! error TS2420: Class 'C1' incorrectly implements interface 'IFoo1'.
!!! error TS2420: Types of property 'p1' are incompatible.
!!! error TS2420: Type '() => string' is not assignable to type '() => number'.
!!! error TS2420: Type 'string' is not assignable to type 'number'.
2014-07-13 01:04:16 +02:00
public p1() {
return "s";
}
}
interface IFoo2 {
p1(s:string): number;
}
class C2 implements IFoo2 { // incompatible on the param type
~~
2014-10-28 08:28:59 +01:00
!!! error TS2420: Class 'C2' incorrectly implements interface 'IFoo2'.
!!! error TS2420: Types of property 'p1' are incompatible.
!!! error TS2420: Type '(n: number) => number' is not assignable to type '(s: string) => number'.
!!! error TS2420: Types of parameters 'n' and 's' are incompatible.
!!! error TS2420: Type 'number' is not assignable to type 'string'.
2014-07-13 01:04:16 +02:00
public p1(n:number) {
return 0;
}
}
interface IFoo3 {
p1: string;
}
class C3 implements IFoo3 { // incompatible on the property type
~~
2014-10-28 08:28:59 +01:00
!!! error TS2420: Class 'C3' incorrectly implements interface 'IFoo3'.
!!! error TS2420: Types of property 'p1' are incompatible.
!!! error TS2420: Type 'number' is not assignable to type 'string'.
2014-07-13 01:04:16 +02:00
public p1: number;
}
interface IFoo4 {
p1: { a: { a: string; }; b: string; };
}
class C4 implements IFoo4 { // incompatible on the property type
~~
2014-10-28 08:28:59 +01:00
!!! error TS2420: Class 'C4' incorrectly implements interface 'IFoo4'.
!!! error TS2420: Types of property 'p1' are incompatible.
!!! error TS2420: Type '{ c: { b: string; }; d: string; }' is not assignable to type '{ a: { a: string; }; b: string; }'.
!!! error TS2420: Property 'a' is missing in type '{ c: { b: string; }; d: string; }'.
2014-07-13 01:04:16 +02:00
public p1: { c: { b: string; }; d: string; };
}
function if1(i: IFoo1): void;
function if1(i: IFoo2): void;
function if1(a: any) { }
var c1: C1;
var c2: C2;
if1(c1);
2014-07-25 02:00:03 +02:00
~~
2014-09-12 00:19:57 +02:00
!!! error TS2345: Argument of type 'C1' is not assignable to parameter of type 'IFoo2'.
2014-07-13 01:04:16 +02:00
function of1(n: { a: { a: string; }; b: string; }): number;
function of1(s: { c: { b: string; }; d: string; }): string;
function of1(a: any) { return null; }
of1({ e: 0, f: 0 });
2014-07-25 02:00:03 +02:00
~~~~~~~~~~~~~~
2014-09-12 00:19:57 +02:00
!!! error TS2345: Argument of type '{ e: number; f: number; }' is not assignable to parameter of type '{ c: { b: string; }; d: string; }'.
!!! error TS2345: Property 'c' is missing in type '{ e: number; f: number; }'.
2014-07-13 01:04:16 +02:00
interface IMap {
[key:string]:string;
}
function foo(fn:() => void) {
}
function bar() {
var map:IMap;
foo(() => {
map = {};
});
}
var o1: { a: { a: string; }; b: string; } = { e: 0, f: 0 };
2014-07-19 02:30:06 +02:00
~~
2014-11-05 21:26:03 +01:00
!!! error TS2322: Type '{ e: number; f: number; }' is not assignable to type '{ a: { a: string; }; b: string; }'.
!!! error TS2322: Property 'a' is missing in type '{ e: number; f: number; }'.
2014-07-13 01:04:16 +02:00
var a1 = [{ e: 0, f: 0 }, { e: 0, f: 0 }, { e: 0, g: 0 }];
var i1c1: { (): string; } = 5;
2014-07-19 02:30:06 +02:00
~~~~
2014-11-05 21:26:03 +01:00
!!! error TS2322: Type 'number' is not assignable to type '() => string'.
2014-07-13 01:04:16 +02:00
var fp1: () =>any = a => 0;
2014-07-19 02:30:06 +02:00
~~~
2014-11-05 21:26:03 +01:00
!!! error TS2322: Type '(a: any) => number' is not assignable to type '() => any'.
2014-07-13 01:04:16 +02:00