Skip to content

Design Meeting Notes, 10/10/2025 #62617

@DanielRosenwasser

Description

@DanielRosenwasser

Rethinking Rest Destructuring on Generic Targets

#62572

function f1<T extends object>(obj: T, key: keyof T) {
    const { [key]: removedValue, ...rest } = obj; // currently, `rest` is `Omit<T, keyof T>`
    return rest;
}
  • rest is Omit<T, keyof T>, which is effectively object (or worse/weirder because it's like Record<never, ...>).
  • Would want rest to be Partial<T> instead of Omit<T, keyof T> so that it is still useful.
  • What patterns does this generalize to beyond something as specific as using T and keyof T?
  • Isn't the right thing to add a K extends keyof T instead?
    • Why didn't the original code do that?
    • Probably just didn't think to add the type parameter?
      • Could imagine that knowing this specific pattern would lead to us conjuring up a type parameter bounded to keyof T so that we could get Omit<T, (some specific keyof T)>.
  • We have a more precise approach, it's not the worst that we don't automatically model this specific code.
  • Aside, why don't we have homomorphic Omit?

Change default --target to esnext esCURRENT

#62198

  • Double-checking: are we okay with this idea?
  • Breaks people without specified target.
  • Kind of weird because there is stuff that is "speculative" because it's only stage 3.
  • Would be better if there was eslatest instead of esnext that was more stable.
    • Maybe esstable, escurrent, esmodern, esstandard?
  • Basically just refers to the latest stable version of ECMAScript.
  • Probably would want the same for lib?
  • So the idea is that eslatest is just an alias for e.g. es202X.
  • We feel like having either esnext or some eslatest be the default makes sense because anything other than "oldest" is arbitrary.
  • Maybe we don't need a specific name here, but we just default to the latest stable version of ECMAScript.
    • So this year it's es2025, next year it's es2026, etc.
  • This helps with the concern about code that uses modern features, but expects syntax that most runtimes don't support to be downleveled.
  • By the way, do we need to change --init?
    • Probably - either omit the target or set it to the latest stable version.

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