| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Aleksey-Bykov Now you can retire the shirt! |
Sorry, something went wrong.
|
Anders Hejlsberg (@ahejlsberg) this is one of all time grand features of TS since unions, type guards and exhaustive switches, it brings point free programming style like what you can find in big boy's FP languages, thank you for your hard work and consideration |
Sorry, something went wrong.
|
Great work! One issue that still stands is #16107. As #16368 is already a breaking change, is it now the time to correct the union inference wart as well? I hope it is. |
Sorry, something went wrong.
| } | ||
| } | ||
| else if (sourceSignatures.length === 1 && targetSignatures.length === 1) { | ||
| // For pure functions (functions with a single signature) we only erase type parameters for |
There was a problem hiding this comment.
Maybe simple/just/only functions would be a better name than pure, as pure brings a different connotation.
Sorry, something went wrong.
There was a problem hiding this comment.
Agreed. Will fix.
Sorry, something went wrong.
# Conflicts: # src/compiler/checker.ts
|
Latest commits add a --noStrictGenericChecks compiler option to disable the stricter generic signature checks. Existing projects can use this as a stopgap solution until errors resulting from the stricter checking are corrected. |
Sorry, something went wrong.
Due to stricter generic type checks, signatures for ZoneAwarePromise need to be changed. See microsoft/TypeScript#16368 The signatures from lib.es5.d.ts were copied over for .then and .catch.
Due to stricter generic type checks, signatures for ZoneAwarePromise need to be changed. See microsoft/TypeScript#16368 The signatures from lib.es5.d.ts were copied over for .then and .catch.
Due to stricter generic type checks, signatures for ZoneAwarePromise need to be changed. See microsoft/TypeScript#16368 The signatures from lib.es5.d.ts were copied over for .then and .catch.
Due to stricter generic type checks, signatures for ZoneAwarePromise need to be changed. See microsoft/TypeScript#16368 The signatures from lib.es5.d.ts were copied over for .then and .catch.
| Back | FazBrowse Home | New Git URL |
This PR complements #16305 by implementing stricter checking of type relationships for generic signatures. Previously, when checking type relationships for generic signatures we would always first erase type parameters (by substituting type any for the type parameters). Now, we properly unify the type parameters by first inferring from the target signature to the source signature and then instantiating the source signature with the inferences. For example:
Previously, no errors were reported above because S, T, and U were replaced by any, causing the signatures to become identical. Now, once we unify the type parameters we can correctly determine that A is assignable to B, but not vice versa. Specifically, in the first assignment we infer T | U for S which after instantiation yields a signature that isn't assignable to A, whereas in the second assignment we infer S for each of T and U which after instantiation yields the same signature as B.
Note that we perform unification only when the source and target types each have a single signature. When either the source or target has multiple signatures (i.e. overloads) we still resort to type parameter erasure as it otherwise becomes prohibitively expensive to determine the relationships.
This PR is technically a breaking change as we now uncover errors we previously wouldn't catch. For this reason we have included a --noStrictGenericChecks compiler option to disable the stricter generic signature checks. Existing projects can use this as a stopgap solution until errors resulting from the stricter checking are corrected.
Fixes #138, #3410, #5616.