| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
I was told "if you get Anders interested in your typings issue, it'll be implemented in a few hours" Apparently the legend is real. |
Sorry, something went wrong.
| // not contain anyFunctionType when we come back to this argument for its second round | ||
| // of inference. | ||
| if (source.flags & TypeFlags.ContainsAnyFunctionType) { | ||
| if (source.flags & TypeFlags.ContainsAnyFunctionType || source === silentNeverType) { |
There was a problem hiding this comment.
worth adding a note on the use of silentNeverType as a marker here.
Sorry, something went wrong.
| inferences.primary || (inferences.primary = []); | ||
| if (!contains(candidates, source)) { | ||
| candidates.push(source); | ||
| for (const inference of inferences) { |
There was a problem hiding this comment.
getInferenceInfoForType here as well?
Sorry, something went wrong.
contextual type is not propagated/instantiated correctly yet. |
Sorry, something went wrong.
|
Anders Hejlsberg (@ahejlsberg):
If that's still outstanding, might there be any PR/branch we could follow on that? |
Sorry, something went wrong.
Mohamed Hegazy (@mhegazy) - I'm liking the use of the word "yet" above 👍 😄 |
Sorry, something went wrong.
|
Where can we track progress against the following bug? type Function1<T1, R> = (t1: T1) => R
function pipe<T1, R>(fn: Function1<T1, R>): Function1<T1, R> {
return fn
}
/// test
function identity<A>(a: A): A { return a }
const pipedIdentity = pipe(identity)
// x is a {}, not a number
const x = pipedIdentity(33) |
Sorry, something went wrong.
|
Alexandre Galays (@AlexGalays) see #9366 and the linked issues. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
With this PR we improve type argument inference by inferring from the contextual type of a generic function call to the return type of the generic function. For example:
Previously the two assignments above would error because {} was inferred for T. We now infer from the contextual type (i.e. the type of the variable to which the function result is assigned).
A more elaborate example:
Inferences made from generic function return types have lower priority than inferences made from arguments to the generic function. For example, the type of s is inferred as string (not Object) in the following:
This PR is a precursor for inferring higher order function types when no inferences can be made for one or more type parameters.
We currently infer (x: {}) => { p: {}[] }, but ideally we'd infer <A>(x: A) => { p: A[] }. That's next on the list.
Fixes #15680.