Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Array method definition revamp: Use case collection

See original GitHub issue

We’ve gotten numerous issue reports and PRs to change the methods of Array, particularly reduce, map, and filter. The built-in test suite doesn’t cover these very well, and these methods interact with each other and the surrounding contextual type in fairly subtle ways.

@jablko has done a great job at #33645 collecting a variety of issues into a single PR; we need to augment this PR (or something like this) with a proper test suite so we can be sure about what’s being changed.

I’d like to create a clearinghouse issue here to collect self-contained (I CANNOT POSSIBLY STRESS THIS ENOUGH, SELF-CONTAINED, DO NOT IMPORT FROM RXJS OR WHAT HAVE YOU) code samples that make use of the array methods.

Please include with your snippet:

  • Compiler settings
  • Compiler version you were testing with
  • The expected behavior (examples that should and should not produce errors are both useful)
  • No imports or exports; snippets need to be self-contained so that we can put them into our test suite without extra complications

Once we’ve established a critical mass of code snippets, we can start combining the existing PRs into an all-up revamp and assess its impact to real-world code suites to figure out which changes don’t result in unacceptable breaking changes.


Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:49
  • Comments:54 (22 by maintainers)

github_iconTop GitHub Comments

ExE-Bosscommented, Sep 25, 2020

I believe that .map(…) operations on tuple types should still produce a tuple type.

RyanCavanaughcommented, Jan 31, 2020

From #24579: flat should, well, flatten. Tested on 3.8-beta with target: ESNext, strict on

declare let arr: [[number, boolean], string];
let x0 = arr.flat(0); // Should be [[number, boolean], string] or (number | boolean | string)[]
let x1 = arr.flat(1); // Should be [number, boolean, string] or (number | boolean | string)[] 
let x2 = arr.flat(2); // Should be [number, boolean, string] or (number | boolean | string)[]
Read more comments on GitHub >

github_iconTop Results From Across the Web

The JavaScript Array Handbook – JS Array Methods ...
In programming, an array is a collection of elements or items. Arrays store data as elements and retrieve them back when you need...
Read more >
5 Badass Array Methods With Real Use Cases - Medium
This method simply applies a function against an accumulator (gathers the values) and each element in the array to reduce it to a...
Read more >
11 Ways to Fully Revamp Your Low Code Application Platform
Expand low code use cases: One way to revamp your low code application platform is to expand the types of applications built using...
Read more >
The Use-Case-Driven Guide to JavaScript Array Methods
Manipulating arrays · Add an element to the end of an array · Remove the last element from an array · Combine two...
Read more >
SciPy 1.9.0 Release Notes — SciPy v1.9.3 Manual
Added new spline based interpolation methods for scipy.interpolate. ... Edge cases for multidimensional arrays, such as when axis-slices have no unmasked ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found