Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Design Meeting Notes, 5/26/2017 #16114

Copy link
Copy link
@DanielRosenwasser

Description

@DanielRosenwasser
Issue body actions

Propagated Inference for Uninstantiated (Free) Type Parameters (#9366)

Given #16072, we can now make more powerful inferences given contextual types on the return type of a call.

However, given the following:

function compose<A, B, C>(
    f: (x: A) => B,
    g: (y: B) => C,
): (x: A) => C;

compose(
    x => [x],
    y => ({ foo: x })
)
  • Right now we just fall back to the instantiations of A = {}, B = {}, C = {}.
  • This is unfortunate because in this scenario, there is no real constraint on the types of the parameters.
    • Ideally, because these are universal functions, the return type should still be a generic function: `(x: A) => { foo: A }
  • We've managed to get this working.
  • This pretty much always works well if your function arguments are less specific in their constraints than those of the invoked expression.
    • Doesn't work for certain cases when the opposite is true.
  • @gcnew has an implementation that can handle some of these cases.
  • Will investigate on a combined approach.

@mhegazy may have notes on weak types (#16047) and synthesized namespace records (#16093)

Reactions are currently unavailable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design NotesNotes from our design meetingsNotes from our design meetings

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.