Repository navigation
Generic checking error #18387
Description
Activity
#16368 is about generic signatures, and i do not see any generic signatures in the code sample in the OP. so please share some context on what is failing, what is the error that is reported, and why do you believe the error is incorrect.
Before #16368, when generic signatures where compared, all generic parameters were erased to
anythen the comparison is done. #16368 adds a correct and more strict comparison by instantiating the source in the generic type arguments of the target before doing the check.- addedNeeds More InfoThe issue still hasn't been fully clarifiedThe issue still hasn't been fully clarified
on Sep 11, 2017 Sorry forgot to include the errors. I updated the OP.
UserextendsModel, andMis constrained to be at leastModel. I think it is weird whyUseris not assignable toM?#16368 introduced the compilation flag
--noStrictGenericChecks. So I would assume it introduced the breaking change. Because when I compile with that flag, no errors occurs.here is a simpler repro:
//type CollectionClass = typeof Collection; type CollectionClass = { new <M extends Model>(): Collection<M> }; type UserCollectionClass = { new(): Collection<User> }; declare let a: CollectionClass; declare let u: UserCollectionClass; a = u; // User is not assignable to M
the check here is telling you that you are replacing a generic function (constructor function for
Collection<M>) with one that is more specific one (constructor function forUserCollection) which is not allowed.OK I see, thanks for the explanation.
- locked and limited conversation to collaborators
on Jun 14, 2018
I think #16368 broke this code for me:
If I provide the
--noStrictGenericChecksflag, it compiles without any complaints. Can I correct this without using the flag?