Skip to content
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 at method #40697

Closed
wants to merge 11 commits into from
Closed

Add at method #40697

wants to merge 11 commits into from

Conversation

Kingwl
Copy link
Contributor

@Kingwl Kingwl commented Sep 22, 2020

Fixes #40695

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Sep 22, 2020
@sandersn sandersn requested a review from rbuckton October 5, 2020 18:44
@typescript-bot typescript-bot added For Milestone Bug PRs that fix a bug with a specific milestone and removed For Uncommitted Bug PR for untriaged, rejected, closed or missing bug labels Oct 5, 2020
@Kingwl
Copy link
Contributor Author

Kingwl commented Nov 12, 2020

Up.

@Jack-Works
Copy link
Contributor

This proposal has web combability problem so it's need to be renamed.

@Kingwl
Copy link
Contributor Author

Kingwl commented Nov 12, 2020

@rbuckton
Copy link
Member

FYI, per the linked issue, item could not be used in ECMAScript due to web compatibility issues. See #40695 (comment)

@typescript-bot
Copy link
Collaborator

The TypeScript team hasn't accepted the linked issue #40695. If you can get it accepted, this PR will have a better chance of being reviewed.

src/lib/esnext.string.d.ts Outdated Show resolved Hide resolved
src/compiler/commandLineParser.ts Show resolved Hide resolved
src/lib/esnext.array.d.ts Show resolved Hide resolved
@@ -295,7 +295,11 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.bigint', 'esnext.string', 'esnext.promise'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', " +
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's painful when you edit something on a very very very long line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should convert these into baseline/snapshot tests. Not necessary for you to do in this PR, so I've filed #44950 to keep track of the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I revert these changes?...

@Kingwl Kingwl changed the title Add item method Add at method Jun 9, 2021
src/lib/esnext.string.d.ts Outdated Show resolved Hide resolved
Kingwl and others added 2 commits June 9, 2021 14:07
Co-authored-by: Anonymous <65428781+CrimsonCodes0@users.noreply.github.com>
Copy link
Member

@rbuckton rbuckton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming there are no further web compatibility issues with .at, this looks good to me. The feature is shipping in both v8 and SpiderMonkey, so it seems fairly stable.

src/compiler/commandLineParser.ts Outdated Show resolved Hide resolved
src/lib/esnext.array.d.ts Show resolved Hide resolved
src/lib/esnext.string.d.ts Show resolved Hide resolved
@@ -295,7 +295,11 @@ namespace ts {
file: undefined,
start: 0,
length: 0,
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'esnext.array', 'esnext.symbol', 'esnext.intl', 'esnext.bigint', 'esnext.bigint', 'esnext.string', 'esnext.promise'.",
messageText: "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'esnext', 'dom', 'dom.iterable', 'webworker', " +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should convert these into baseline/snapshot tests. Not necessary for you to do in this PR, so I've filed #44950 to keep track of the issue.

Copy link
Member

@rbuckton rbuckton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was supposed to be a request changes, sorry.

Copy link

@felipeplets felipeplets left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@sandersn
Copy link
Member

sandersn commented Aug 20, 2021

We discussed this in the design meeting and concluded:

  1. at should return T | undefined, as this PR does.
  2. The compiler should add support for negative indices on tuples, along with special support for at to work the same way. Something like
declare let t: [string, number]
let n = t.at(-1) // n: number
type TN = (typeof t)[-1] // also number?
// and perhaps even
declare let t2: [...string, number]
let n2 = t.at(-1)

Though the second example would require adding quite a bit more code to the checker.

I expect @DanielRosenwasser will link the notes when he's done preparing them.

@sandersn
Copy link
Member

@rbuckton Can you take another look and merge if all your comments have been addressed?

@rbuckton
Copy link
Member

rbuckton commented Feb 1, 2022

It looks like a different PR was merged that already addressed this: #46291

@rbuckton rbuckton closed this Feb 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Milestone Bug PRs that fix a bug with a specific milestone
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add support of Item method (stage 3)
6 participants