- Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed
Description
TypeScript Version: Version 2.4.0-dev.20170517
In the code below, I am am uncertain if this is a bug or a misunderstanding on my part to do with the new, more restrictive, 'object' type.
Code
// The following produces a compiler error:// Type 'A & B' does not satisfy the constraint 'Base'.// Type 'A & B' is not assignable to type 'object'.// (type parameter) B in foo<A extends Base, B extends Base>(): Foo<Base, A & B>//typeBase=boolean|object;typeFoo<DOM,CODOMextendsDOM>=(dom: DOM)=>CODOM;functionfoo<AextendsBase,BextendsBase>(): Foo<Base,A&B>// <= error at A & B{return<any>function(x: Base){returnx;};}// Removing the constraint on CODOM in type Foo2 and// all is well.//typeBase2=boolean|object;typeFoo2<DOM,CODOM>=(dom: DOM)=>CODOM;// <= "fixed" by removing extends DOMfunctionfoo2<AextendsBase2,BextendsBase2>(): Foo2<Base2,A&B>{return<any>function(x: Base2){returnx;};}// All can also be made well by changing object to Object in// type Base3.//typeBase3=boolean|Object;// <= also "fixed" by resorting to 'Object' instead of 'object'typeFoo3<DOM,CODOMextendsDOM>=(dom: DOM)=>CODOM;functionfoo3<AextendsBase3,BextendsBase3>(): Foo3<Base3,A&B>{return<any>function(x: Base2){returnx;};}Metadata
Metadata
Assignees
Labels
Design LimitationConstraints of the existing architecture prevent this from being fixedConstraints of the existing architecture prevent this from being fixed