File: classIsSubtypeOfBaseType.errors.txt

package info (click to toggle)
node-typescript 2.1.5-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 203,952 kB
  • ctags: 52,987
  • sloc: sh: 11; makefile: 5
file content (27 lines) | stat: -rw-r--r-- 1,256 bytes parent folder | download | duplicates (2)
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
tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts(11,7): error TS2415: Class 'Derived2' incorrectly extends base class 'Base<{ bar: string; }>'.
  Types of property 'foo' are incompatible.
    Type '{ bar?: string; }' is not assignable to type '{ bar: string; }'.
      Property 'bar' is optional in type '{ bar?: string; }' but required in type '{ bar: string; }'.


==== tests/cases/conformance/classes/classDeclarations/classHeritageSpecification/classIsSubtypeOfBaseType.ts (1 errors) ====
    class Base<T> {
        foo: T;
    }
    
    class Derived extends Base<{ bar: string; }> {
        foo: {
            bar: string; baz: number; // ok
        }
    }
    
    class Derived2 extends Base<{ bar: string; }> {
          ~~~~~~~~
!!! error TS2415: Class 'Derived2' incorrectly extends base class 'Base<{ bar: string; }>'.
!!! error TS2415:   Types of property 'foo' are incompatible.
!!! error TS2415:     Type '{ bar?: string; }' is not assignable to type '{ bar: string; }'.
!!! error TS2415:       Property 'bar' is optional in type '{ bar?: string; }' but required in type '{ bar: string; }'.
        foo: {
            bar?: string; // error
        }
    }