Skip to content

Design Meeting Notes, 3/22/2019 #30547

Closed
Closed
@DanielRosenwasser

Description

@DanielRosenwasser

Avoiding fixing during inference

  • Requesting the type of a type parameter T for a function expression for contextual typing often "fixes" a type parameter to its constraint {}.
  • Idea: when a function expression needs a contextual type, give the "current" view of the type to get the left side, but don't fix the type.

3.4 Breaks

#30390

  • Not just "we do inference better so we catch more bugs"
    • Maybe this is a larger problem - people really don't mean true | false when we say boolean.
  • Have this implicit assumption that when you have an explicit return type annotation, when you return something that's assignable to that type, it should be "fine".
    • Not true here.
  • The literal types might be defensible. The problem is that we've discarded at least one branch of inference.

#30419

Remove block-scoped bindings from globalThis

#30477
#30510

  • Turns out let and const and class shouldn't show up on this, global, window, or globalThis.
    • Uh oh. That's how it works in master.
    • We've never made a differentiation between
  • Complications
    • We'd also have to change things in the global scope like Object, Number, String back from const to var
    • But you can change them! Why were they ever const?
      • Because you can "technically" do a lot of stuff in an untyped language, but that's not our bar.
  • So how do you express a constant var?
    • const var?
    • readonly var?
    • public static void readonly virtual var?
    • Not 3.4-prioritized.
  • We also down-level const to var.
    • Technically, at runtime you can access
  • Sounds like we should do this today.
  • Also, add a keyof typeof globalThis?

Strictly-typed Generators

#2983

  • First we needed boolean literal types.
  • Then we needed to not break Node so we needed typesVersions.
  • But we'd still hit a big breaking change by changing the type.
  • Started looking into a strictGeneratorTypes so this becomes opt-in
    • Strongly typed return types, and strongly typed yield as well.
    • You can annotate the return type of a generator to be Generator<YieldOutputType, OutputType, NextInputType>
    • yield expressions use contextual types to infer their input type (i.e. what a caller can give when they have .next()).
  • Can we do this without putting it under strict?
  • [[Out of time]]

Metadata

Metadata

Assignees

No one assigned

    Labels

    Design NotesNotes from our design meetings

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions