Skip to content

Fixed expando functions with symbol-only properties #54726

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 3 commits into from
Jul 20, 2023

Conversation

Andarist
Copy link
Contributor

fixes #54220

@typescript-bot typescript-bot added the For Backlog Bug PRs that fix a backlog bug label Jun 21, 2023
let indexInfos: IndexInfo[] | undefined;
if (symbol.exports) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

From what I understand symbol.exports only are only meant to keep properties that pass isTypeUsableAsPropertyName test and this symbol table is lazily created. Since symbols don't pass this test there was a chance for the symbol.exports table to not be created at all.

This patch essentially just grabs getExportsOfSymbol earlier.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is also still a question if this should be an error in JS files - since that PR doesn't change the behavior in JS. I'm not sure what's expected here though since both expando functions and JS files have their own unique rules

Copy link
Member

Choose a reason for hiding this comment

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

The same code should work in JS. I'm guessing this change does that--can you add a test for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I added the JS-oriented test case (with types declared in a TS file since I have no idea how to declare a computed property in JSDoc). I also have no idea what I had in mind here when posting that comment - this code here isn't targeting TS files (or non-JS files or anything like that) 😅

@Andarist Andarist force-pushed the fix/expando-functions-with-symbols branch from cb60cc8 to 761d637 Compare June 21, 2023 16:15
Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

Needs a test for JS. Also, I need to sit down with an editor and figure out if moving the getExportsOfSymbol call will hurt circularity prevention. At least, that's what I remember as the reason for let members = emptySymbols; maybe it was just a convenient initialiser.

let indexInfos: IndexInfo[] | undefined;
if (symbol.exports) {
Copy link
Member

Choose a reason for hiding this comment

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

The same code should work in JS. I'm guessing this change does that--can you add a test for it?

@sandersn sandersn self-assigned this Jul 19, 2023
@sandersn sandersn requested a review from rbuckton July 19, 2023 22:49
Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

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

I was thinking of the call to setStructuredTypeMembers just below the block you changed. This change shouldn't hurt resolution of circular types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For Backlog Bug PRs that fix a backlog bug
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Element implicitly has an 'any' type because expression of type 'unique symbol' can't be used to index function type
3 participants