Skip to content

Support __proto__ in object literal (type-check only) - #48816

Closed
Jack Works (Jack-Works) wants to merge 2 commits into
microsoft:mainfrom
Jack-Works:proto-literal-type-checking
Closed

Jack Works (Jack-Works) wants to merge 2 commits into
microsoft:mainfrom
Jack-Works:proto-literal-type-checking

Conversation

@Jack-Works

Copy link
Copy Markdown
Contributor

@typescript-bot TypeScript Bot (typescript-bot) added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Apr 23, 2022
@typescript-bot

Copy link
Copy Markdown
Contributor

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

@DanielRosenwasser

Copy link
Copy Markdown
Member

To be honest, I don't think we want the complexity of ever thinking about __proto__ in TypeScript. The corresponding issue received 2 votes over 5 years, so I don't think it would make sense to bring this change in.

@bakkot

Copy link
Copy Markdown
Contributor

#39882 has another 11, from a mostly different set of people.

Anyway, while I think it's fair to not want to think about prototypes, it seems a shame to say that let x = { __proto__: null }; is forever going to be typed as an object with a __proto__ property of null, meaning that __proto__ is suggested in autocompletes and so on.

@Josh-Cena

Copy link
Copy Markdown
Contributor

It's standard ECMAScript syntax, so even if we don't bring in the whole prototypical semantics, it should at least be special-cased to not mess with valid things like const map: Record<string, string> = { __proto__: null }

@Jack-Works

Copy link
Copy Markdown
Contributor Author

This PR doesn't bring "prototype" into the type system. It will treat { __proto__: x, ...rest } as type typeof { ...x, ...rest }.

@sandersn

Copy link
Copy Markdown
Member

Kevin Gibbons (@bakkot) Joshua Chen (@Josh-Cena) Jack Works (@Jack-Works) can you make your case on an issue instead of on a PR? Changes to checker.ts, especially, bit-rot quickly and technical concerns get confused with semantics.

@sandersn

Copy link
Copy Markdown
Member

To help with PR housekeeping, I'm going to close this PR while it's still waiting on its bug to be accepted. We can open again once that happens.

@microsoft Microsoft (microsoft) locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

Ignore __proto__

6 participants