Skip to content

Allow global Symbol computed names during pseudochecker object literal serialization#3297

Open
Andarist wants to merge 2 commits intomicrosoft:mainfrom
Andarist:fix/id-definitely-symbol-methods
Open

Allow global Symbol computed names during pseudochecker object literal serialization#3297
Andarist wants to merge 2 commits intomicrosoft:mainfrom
Andarist:fix/id-definitely-symbol-methods

Conversation

@Andarist
Copy link
Copy Markdown
Contributor

This change matches Strada's behavior more closely

export const symbolNamed = {
[Symbol.toStringTag]: "demo",
[Symbol.iterator]() {
return [1, 2, 3][Symbol.iterator]();
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

In Strada, this reports a slightly different error (TS playground):

Method must have an explicit return type annotation with --isolatedDeclarations.

expression := e.Name().Expression()
if !ast.IsPrimitiveLiteralValue(expression, false) {
if !ast.IsPrimitiveLiteralValue(expression, false) &&
!ch.isDefinitelyReferenceToGlobalSymbolObject(expression) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not super fond of coupling the pseudochecker with a checker's method like this but this is kinda the earliest moment at which this thing can be checked without doubling the work somewhere else.

I tried putting this in the nodebuilder but that had its own issues and was allowing all computed properties in the pseudochecker, just so the nodebuilder could reject them

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd go so far as to say it's a bad idea that goes against the premise of the ID pseudochecker. The functionality needs to be implementable without a full check to be consistent with ID's goals.

Copy link
Copy Markdown
Member

@weswigham weswigham Mar 30, 2026

Choose a reason for hiding this comment

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

Fortunately, it seems like isDefinitelyReferenceToGlobalSymbolObject seems like it's not too bad to implement an equivalent outside the checker? You just need the binder's reference resolver instead.

@Andarist Andarist force-pushed the fix/id-definitely-symbol-methods branch from 8534285 to 611d271 Compare March 30, 2026 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants