48 lines
No EOL
2.3 KiB
Text
48 lines
No EOL
2.3 KiB
Text
tests/cases/compiler/overloadingOnConstants1.ts(22,5): error TS2322: Type 'Base' is not assignable to type 'Derived1'.
|
|
Property 'bar' is missing in type 'Base'.
|
|
tests/cases/compiler/overloadingOnConstants1.ts(23,5): error TS2322: Type 'Derived1' is not assignable to type 'Derived3'.
|
|
Property 'biz' is missing in type 'Derived1'.
|
|
tests/cases/compiler/overloadingOnConstants1.ts(24,5): error TS2322: Type 'Derived2' is not assignable to type 'Derived1'.
|
|
Property 'bar' is missing in type 'Derived2'.
|
|
tests/cases/compiler/overloadingOnConstants1.ts(25,5): error TS2322: Type 'Derived3' is not assignable to type 'Derived1'.
|
|
Property 'bar' is missing in type 'Derived3'.
|
|
|
|
|
|
==== tests/cases/compiler/overloadingOnConstants1.ts (4 errors) ====
|
|
class Base { foo() { } }
|
|
class Derived1 extends Base { bar() { } }
|
|
class Derived2 extends Base { baz() { } }
|
|
class Derived3 extends Base { biz() { } }
|
|
|
|
interface Document2 {
|
|
createElement(tagName: 'canvas'): Derived1;
|
|
createElement(tagName: 'div'): Derived2;
|
|
createElement(tagName: 'span'): Derived3;
|
|
createElement(tagName: string): Base;
|
|
}
|
|
|
|
var d2: Document2;
|
|
|
|
// these are ok
|
|
var htmlElement: Base = d2.createElement("yo")
|
|
var htmlCanvasElement: Derived1 = d2.createElement("canvas");
|
|
var htmlDivElement: Derived2 = d2.createElement("div");
|
|
var htmlSpanElement: Derived3 = d2.createElement("span");
|
|
|
|
// these are errors
|
|
var htmlElement2: Derived1 = d2.createElement("yo")
|
|
~~~~~~~~~~~~
|
|
!!! error TS2322: Type 'Base' is not assignable to type 'Derived1'.
|
|
!!! error TS2322: Property 'bar' is missing in type 'Base'.
|
|
var htmlCanvasElement2: Derived3 = d2.createElement("canvas");
|
|
~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2322: Type 'Derived1' is not assignable to type 'Derived3'.
|
|
!!! error TS2322: Property 'biz' is missing in type 'Derived1'.
|
|
var htmlDivElement2: Derived1 = d2.createElement("div");
|
|
~~~~~~~~~~~~~~~
|
|
!!! error TS2322: Type 'Derived2' is not assignable to type 'Derived1'.
|
|
!!! error TS2322: Property 'bar' is missing in type 'Derived2'.
|
|
var htmlSpanElement2: Derived1 = d2.createElement("span");
|
|
~~~~~~~~~~~~~~~~
|
|
!!! error TS2322: Type 'Derived3' is not assignable to type 'Derived1'.
|
|
!!! error TS2322: Property 'bar' is missing in type 'Derived3'. |