-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Add Array.prototype.findLast
and Array.prototype.findLastIndex
#48829
Comments
[Double checking with @DanielRosenwasser that stage 3 is the only criteria for adding to lib.esnext] |
It is, but if I ask for stage 4 at an upcoming meeting we might as well add it to a stable version. |
Seems weird that Firefox hasn’t implemented it yet, that’s a bit unfortunate. |
Sorry....My fault. |
@Kingwl It’s your fault that Firefox doesn’t support this API? What? |
@fatcerberus, the context is that @Kingwl is contributing the changeset to Firefox. By the way, we reached Stage 4 today! 🎉🎉🎉 I believe that means we should add this to |
Array.prototype.findLast
and Array.prototype.findLastIndex
Array.prototype.findLast
and Array.prototype.findLastIndex
With which version of typescript I could use the method findLast? |
@monikams I found a temporally solution for this problem, just create a export {}
declare global {
interface Array<T> {
findLastIndex(
predicate: (value: T, index: number, obj: T[]) => unknown,
thisArg?: any
): number
}
} Ready! You can use this approach without wrongs from your typescript linter. |
|
Is adding these methods a breaking change? Why has this been moved to the 5.0 milestone? Thanks |
5.0 is just the next release. |
…s will be fixed in typescript version 5, short term fix is to add to globals microsoft/TypeScript#48829
Has this been added for 5.0? I'm really wanting to use |
Any updates? Its a bit funky that we still have to include a custom typing for this... |
It's in TypeScript 5.0 beta and the nightlies. The target release dates are available here. |
Well I upgraded my project to Typescript 5.0.2 today and hoped the errors would go away but nope, I still get:
If I try setting that in my tsconfig.json:
I get the build error:
Can anyone help me out? What am I doing wrong? |
Given the error message, it sounds like you need to upgrade your version of typescript-eslint. |
It seems to be TS itself giving the error. In VS code, the error is suffixed with "ts(2550)". |
Well it's not using that dev version but it is using the 5.0.2 workspace version. Should that have it? |
microsoft/TypeScript#48829 thanks to JunyaFff
It works only in TS 5 and only when the |
Incorrect, as you can see here: As @BR0kEN- said, if you change the Tried also updating to the latest Typyscript |
It is now buit-in since TypeScript v5.0 (microsoft/TypeScript#48829 (comment)).
….prototype.findLast` It is now buit-in since TypeScript v5.0 (microsoft/TypeScript#48829 (comment)).
….prototype.findLast` It is now buit-in since TypeScript v5.0 (microsoft/TypeScript#48829 (comment)).
Is there any progress with this issue? |
Is there any progress on this issue? |
There's not progress because it was fixed in 2022. If you're not seeing |
Ah, it indeed does work, but the problem is indeed that Setting the target to es2023 even in TypeScript 5.3.3 yields the same error I had before. However, In the handbook, you'll see that |
here is the solution make the declaration under your code with findLastIndex
and it will fix your issue |
Got above on my LeetCode solution https://leetcode.com/problems/increasing-decreasing-string MDN says
So I guess that's why. Leetcode yet to update their transpiler/compiler |
lib Update Request
Configuration Check
My compilation target is
ES5
and my lib isESNext
.Missing / Incorrect Definition
Missing
Array.prototype.findLast
andArray.prototype.findLastIndex
Sample Code
Documentation Link
Proposal: https://tc39.es/proposal-array-find-from-last/ (currently stage
34)Can I Use: https://caniuse.com/mdn-javascript_builtins_array_findlast (Chrome and Safari already shipped it without flags)
The text was updated successfully, but these errors were encountered: