72 lines
1.8 KiB
Plaintext
72 lines
1.8 KiB
Plaintext
==== tests/cases/conformance/types/typeRelationships/subtypesAndSuperTypes/subtypingWithObjectMembers5.ts (3 errors) ====
|
|
interface Base {
|
|
foo: string;
|
|
}
|
|
|
|
interface Derived extends Base {
|
|
bar: string;
|
|
}
|
|
|
|
// N and M have the same name, same accessibility, same optionality, and N is a subtype of M
|
|
// foo properties are valid, bar properties cause errors in the derived class declarations
|
|
module NotOptional {
|
|
interface A {
|
|
foo: Base;
|
|
}
|
|
|
|
class B implements A {
|
|
~
|
|
!!! Class 'B' incorrectly implements interface 'A':
|
|
!!! Property 'foo' is missing in type 'B'.
|
|
fooo: Derived; // error
|
|
}
|
|
|
|
interface A2 {
|
|
1: Base;
|
|
}
|
|
|
|
class B2 implements A2 {
|
|
~~
|
|
!!! Class 'B2' incorrectly implements interface 'A2':
|
|
!!! Property '1' is missing in type 'B2'.
|
|
2: Derived; // error
|
|
}
|
|
|
|
interface A3 {
|
|
'1': Base;
|
|
}
|
|
|
|
class B3 implements A3 {
|
|
~~
|
|
!!! Class 'B3' incorrectly implements interface 'A3':
|
|
!!! Property ''1'' is missing in type 'B3'.
|
|
'1.0': Derived; // error
|
|
}
|
|
}
|
|
|
|
// same cases as above but with optional
|
|
module Optional {
|
|
interface A {
|
|
foo?: Base;
|
|
}
|
|
|
|
class B implements A {
|
|
fooo: Derived; // ok
|
|
}
|
|
|
|
interface A2 {
|
|
1?: Base;
|
|
}
|
|
|
|
class B2 implements A2 {
|
|
2: Derived; // ok
|
|
}
|
|
|
|
interface A3 {
|
|
'1'?: Base;
|
|
}
|
|
|
|
class B3 implements A3 {
|
|
'1.0': Derived; // ok
|
|
}
|
|
} |