Skip to content

Add index signature for anonymous object literal type #37903

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

Merged
merged 5 commits into from
Nov 2, 2020

Conversation

okmttdhr
Copy link
Contributor

@okmttdhr okmttdhr commented Apr 11, 2020

Fixes #14951
Related to #26710

@okmttdhr okmttdhr marked this pull request as ready for review April 11, 2020 07:21
@sandersn sandersn added the For Backlog Bug PRs that fix a backlog bug label May 5, 2020
@sandersn
Copy link
Member

sandersn commented May 5, 2020

ping @weswigham because I believe you have thought a lot about index signatures.

Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

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

We should implement the new behavior within getPropertyTypeForIndexType, rather than checkElementAccessExpression - specifically if the accessFlags are for Writing, and the originalObjectType passes isObjectTypeWithInferableIndex, and we failed to lookup a property or index signature type. This should mirror the checks we do in comparisons, I think.

@okmttdhr
Copy link
Contributor Author

okmttdhr commented May 9, 2020

@weswigham
Thank you! I'll do this in that way!

I'd appreciate that you'd let me know any test cases I should add, if any!

@okmttdhr okmttdhr requested a review from weswigham May 17, 2020 06:31
@okmttdhr okmttdhr force-pushed the object-literal-index-signature branch from 443ad78 to 2ce92c4 Compare May 17, 2020 06:33
@okmttdhr okmttdhr force-pushed the object-literal-index-signature branch 2 times, most recently from dccfdbb to 8ea849b Compare May 24, 2020 04:23
@okmttdhr okmttdhr requested a review from weswigham May 24, 2020 05:25
Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

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

Whew, sorry for the huge delay - guess I was waiting for a response from @RyanCavanaugh that never came. I lieu of that, this looks broadly good, but I still have two small comments before this seems good to merge.

@typescript-bot typescript-bot added For Uncommitted Bug PR for untriaged, rejected, closed or missing bug and removed For Backlog Bug PRs that fix a backlog bug labels Sep 13, 2020
@okmttdhr okmttdhr force-pushed the object-literal-index-signature branch from 26a35bc to 6eb7900 Compare September 13, 2020 03:50
@okmttdhr okmttdhr force-pushed the object-literal-index-signature branch 2 times, most recently from 50c9007 to 73acd03 Compare September 13, 2020 04:50
@okmttdhr okmttdhr force-pushed the object-literal-index-signature branch from 73acd03 to 5ae218d Compare September 13, 2020 04:51
@okmttdhr okmttdhr requested a review from weswigham September 13, 2020 05:10
@sandersn
Copy link
Member

@weswigham Looking at your last review, and the subsequent commits, I think this is ready to merge once the 4.1 RC is out. Does that sound right to you?

@weswigham
Copy link
Member

Yeah, this looks good now. @sandersn do you want to merge whenever you feel is appropriate?

@sandersn sandersn merged commit 7db5f68 into microsoft:master Nov 2, 2020
@typescript-bot
Copy link
Collaborator

The PR doesn't have any linked issues. Please open an issue that references this PR. From there we can discuss and prioritise.

@okmttdhr okmttdhr deleted the object-literal-index-signature branch November 3, 2020 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Uncommitted Bug PR for untriaged, rejected, closed or missing bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

type has no index signature
4 participants