Skip to content

Design Meeting Notes, 6/10/2022 #49479

Closed
Closed
@DanielRosenwasser

Description

@DanielRosenwasser

Breaks from Checks Against Unconstrained Generics

#49461
#49119
#48923
#48366

function foo<T>(x: T) {
    // Now breaks but is technically correct because
    // T could be null/undefined.
    takeValue(x);
}

foo(100);

function takeValue(obj: {}) {
}
  • It is a "bug fix" for strictNullChecks technically.
  • Why did we pull it out of 4.7?
    • We did not properly narrow generic values.
  • Operating principles are that strict opts you into breaks. strictNullChecks gives you that.
    • Could add an extra switch under strict that could be opted out.
  • Balance between pain and benefit?
  • Mitigations?
    • No quick fix.
      • Never had the quick fix.
    • Related spans in errors?
      • Always suggesting extends object.
      • Real examples were never object.
  • Aside:
    • TypeScript ESLint rules often complain about {} - we don't like that.
  • Conclusion:
    • We do feel like the value is provided while authoring code - hard to see the benefits on existing code. Some cases caught by runtime errors.
    • Would like to provide a better quick fix and error message.
    • Would like to rerun the new-errors reporter.

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