Skip to content

Design Meeting Notes, 8/20/2021 #45551

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
DanielRosenwasser opened this issue Aug 23, 2021 · 3 comments
Closed

Design Meeting Notes, 8/20/2021 #45551

DanielRosenwasser opened this issue Aug 23, 2021 · 3 comments
Labels
Design Notes Notes from our design meetings

Comments

@DanielRosenwasser
Copy link
Member

DanielRosenwasser commented Aug 23, 2021

Track Source and Target Stack Depths Separately

#41821

Array.prototype.at Returning undefined

#45512

  • Can still index outside the range, just also works with negative indexes.
    • Could make that work on tuples, but need more special support.
    • Or, could just bake a hack in for tuples.
      • ...unless you have rests and spreads!
        • ...unless those are front-loaded! (e.g. [...some, ...stuff, 123, true, 'a'].at(-1) could return string)
    • Unclear if we would want to get into the domain of adding type notation support for it.
  • We're fans of making sure this thing has undefined in the return type.
  • Do we need to have the special tuple support before we ship this?
    • Possibly.
  • Seems strange - in Python, experience was using regular arrays, and -1 was the argument that was passed in 99% of the time.
  • 2 things we should do
    • Ship the thing that returns T | undefined in lib.d.ts.
    • Bake in some support for negative indexes when we know better.
@DanielRosenwasser DanielRosenwasser added the Design Notes Notes from our design meetings label Aug 23, 2021
@MartinJohns
Copy link
Contributor

(e.g. [...some, ...stuff, 'c', 'b', 'a'].at(-1) could return -1)

Am I missing something here? How could this possibly return -1?

@DanielRosenwasser
Copy link
Member Author

Thanks! The original code snippet used [...some, ...stuff, -3, -2, -1] but I switched the contents of the array to make it clearer.

@DanielRosenwasser
Copy link
Member Author

Even that was a little bit off - the real example should use a heterogeneous array and not discuss literal types. I guess taking notes during the discussion can throw me off a bit. 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Design Notes Notes from our design meetings
Projects
None yet
Development

No branches or pull requests

2 participants