2014-07-13 01:04:16 +02:00
|
|
|
==== tests/cases/compiler/interfaceDeclaration4.ts (6 errors) ====
|
|
|
|
// Import this module when test harness supports external modules. Also remove the internal module below.
|
|
|
|
// import Foo = require("interfaceDeclaration5")
|
|
|
|
module Foo {
|
|
|
|
export interface I1 { item: string; }
|
|
|
|
export class C1 { }
|
|
|
|
}
|
|
|
|
|
|
|
|
class C1 implements Foo.I1 {
|
|
|
|
public item:string;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Allowed
|
|
|
|
interface I2 extends Foo.I1 {
|
|
|
|
item:string;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Negative Case
|
|
|
|
interface I3 extends Foo.I1 {
|
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2429: Interface 'I3' incorrectly extends interface 'I1':
|
|
|
|
!!! error TS2429: Types of property 'item' are incompatible:
|
|
|
|
!!! error TS2429: Type 'number' is not assignable to type 'string'.
|
2014-07-13 01:04:16 +02:00
|
|
|
item:number;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface I4 extends Foo.I1 {
|
|
|
|
token:string;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Err - not implemented item
|
|
|
|
class C2 implements I4 {
|
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2421: Class 'C2' incorrectly implements interface 'I4':
|
|
|
|
!!! error TS2421: Property 'item' is missing in type 'C2'.
|
2014-07-13 01:04:16 +02:00
|
|
|
public token: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface I5 extends Foo { }
|
|
|
|
|
|
|
|
// Negative case
|
|
|
|
interface I6 extends Foo.C1 { }
|
|
|
|
|
|
|
|
class C3 implements Foo.I1 { }
|
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2421: Class 'C3' incorrectly implements interface 'I1':
|
|
|
|
!!! error TS2421: Property 'item' is missing in type 'C3'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|
|
|
|
// Negative case
|
|
|
|
interface Foo.I1 { }
|
|
|
|
~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS1005: '{' expected.
|
2014-07-13 01:04:16 +02:00
|
|
|
~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS1005: ';' expected.
|
2014-07-13 01:04:16 +02:00
|
|
|
~~
|
2014-09-12 00:19:57 +02:00
|
|
|
!!! error TS2304: Cannot find name 'I1'.
|
2014-07-13 01:04:16 +02:00
|
|
|
|