68 lines
No EOL
3.1 KiB
Text
68 lines
No EOL
3.1 KiB
Text
tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(5,5): error TS2346: Supplied parameters do not match any signature of call target.
|
|
tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(31,12): error TS2352: Neither type 'SomeOther' nor type 'SomeBase' is assignable to the other.
|
|
Property 'p' is missing in type 'SomeOther'.
|
|
tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(35,15): error TS2352: Neither type 'SomeOther' nor type 'SomeDerived' is assignable to the other.
|
|
Property 'x' is missing in type 'SomeOther'.
|
|
tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(37,13): error TS2352: Neither type 'SomeDerived' nor type 'SomeOther' is assignable to the other.
|
|
Property 'q' is missing in type 'SomeDerived'.
|
|
tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts(38,13): error TS2352: Neither type 'SomeBase' nor type 'SomeOther' is assignable to the other.
|
|
Property 'q' is missing in type 'SomeBase'.
|
|
|
|
|
|
==== tests/cases/conformance/expressions/typeAssertions/typeAssertions.ts (5 errors) ====
|
|
// Function call whose argument is a 1 arg generic function call with explicit type arguments
|
|
function fn1<T>(t: T) { }
|
|
function fn2(t: any) { }
|
|
|
|
fn1(fn2<string>(4)); // Error
|
|
~~~~~~~~~~~~~~
|
|
!!! error TS2346: Supplied parameters do not match any signature of call target.
|
|
|
|
var a: any;
|
|
var s: string;
|
|
|
|
// Type assertion of non - unary expression
|
|
var a = <any>"" + 4;
|
|
var s = "" + <any>4;
|
|
|
|
class SomeBase {
|
|
private p;
|
|
}
|
|
class SomeDerived extends SomeBase {
|
|
private x;
|
|
}
|
|
class SomeOther {
|
|
private q;
|
|
}
|
|
|
|
// Type assertion should check for assignability in either direction
|
|
var someBase = new SomeBase();
|
|
var someDerived = new SomeDerived();
|
|
var someOther = new SomeOther();
|
|
|
|
someBase = <SomeBase>someDerived;
|
|
someBase = <SomeBase>someBase;
|
|
someBase = <SomeBase>someOther; // Error
|
|
~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2352: Neither type 'SomeOther' nor type 'SomeBase' is assignable to the other.
|
|
!!! error TS2352: Property 'p' is missing in type 'SomeOther'.
|
|
|
|
someDerived = <SomeDerived>someDerived;
|
|
someDerived = <SomeDerived>someBase;
|
|
someDerived = <SomeDerived>someOther; // Error
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2352: Neither type 'SomeOther' nor type 'SomeDerived' is assignable to the other.
|
|
!!! error TS2352: Property 'x' is missing in type 'SomeOther'.
|
|
|
|
someOther = <SomeOther>someDerived; // Error
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2352: Neither type 'SomeDerived' nor type 'SomeOther' is assignable to the other.
|
|
!!! error TS2352: Property 'q' is missing in type 'SomeDerived'.
|
|
someOther = <SomeOther>someBase; // Error
|
|
~~~~~~~~~~~~~~~~~~~
|
|
!!! error TS2352: Neither type 'SomeBase' nor type 'SomeOther' is assignable to the other.
|
|
!!! error TS2352: Property 'q' is missing in type 'SomeBase'.
|
|
someOther = <SomeOther>someOther;
|
|
|
|
|
|
|