You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceMsgConstructor<TextendsMessage>{new(data: Array<{}>): T;}classMessage{clone(): this {returnthis;}}interfaceMessageList<TextendsMessage>extendsMessage{methodOnMessageList(): T[];}functionfetchMsg<VextendsMessage>(protoCtor: MsgConstructor<V>): V{returnnull!;}classDataProvider<TextendsMessage,UextendsMessageList<T>>{constructor(privatereadonlymessage: MsgConstructor<T>,privatereadonlymessageList: MsgConstructor<U>,){}fetch(){constmessageList=fetchMsg(this.messageList);messageList.methodOnMessageList();}}
Expected behavior:
Compiles, because V is derived to be a subtype of MessageList. This is what it did in TS 2.5.
Actual behavior:
With TS2.6, derivation works differently:
repro.ts(25,17): error TS2339: Property 'methodOnMessageList' does not exist on type 'Message'.
If you explicitly pass fetchMsg<U>(...), you can see why:
repro.ts(24,34): error TS2344: Type 'U' does not satisfy the constraint 'Message'.
Type 'MessageList<T>' is not assignable to type 'Message'.
Types of property 'clone' are incompatible.
Type '() => MessageList<T>' is not assignable to type '() => U'.
Type 'MessageList<T>' is not assignable to type 'U'.
This seems wrong - MessageList inherits from Message, so any MessageList should satisfy the constraint Message.
The text was updated successfully, but these errors were encountered:
TypeScript Version: Version 2.7.0-dev.20180110
Code
Expected behavior:
Compiles, because
V
is derived to be a subtype ofMessageList
. This is what it did in TS 2.5.Actual behavior:
With TS2.6, derivation works differently:
If you explicitly pass
fetchMsg<U>(...)
, you can see why:This seems wrong -
MessageList
inherits fromMessage
, so anyMessageList
should satisfy the constraintMessage
.The text was updated successfully, but these errors were encountered: