Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's wrong with this signature? (typescript-2.5)

Tags:

typescript

I have an interface

export interface ITypeAssertions
    {
         isOfTypeElseFail<TExpected extends TActual, TActual>(value: TActual, oxIsOfType: (xVal: TActual) => boolean): value is TExpected; 
    }

and implementation

export class NodeJsTestingFrameworkAdapter implements ITypeAssertions
{
  isOfTypeElseFail<TExpected extends TActual, TActual>(value: TActual, oxIsOfType: (xVal: TActual) => boolean): value is TExpected
  {
       throw new Error("Method not implemented.");
  }
}

Compiler complains that:

  • interface-not-properly-implemented

    • (...)

      • Type predicate 'value is TActual' is not assignable to 'value is TExpected'
        • Type 'TActual' is not assignable to type 'TExpected'

What's wrong? Is this a bug in a type-checker?

PS. It was compiling fine under Ts-2.3.

like image 273
user3284063 Avatar asked Nov 27 '25 23:11

user3284063


1 Answers

Currently there is no chance to have it working, as it is described in the response under the github.com/Microsoft/TypeScript/issues/18202.

like image 142
user3284063 Avatar answered Nov 29 '25 17:11

user3284063



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!