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

resolver no longer analyzes declare var, but it does analyze declare function #10099

Closed
dsherret opened this issue Feb 25, 2025 · 2 comments · May be fixed by #10102
Closed

resolver no longer analyzes declare var, but it does analyze declare function #10099

dsherret opened this issue Feb 25, 2025 · 2 comments · May be fixed by #10102
Assignees
Labels
Milestone

Comments

@dsherret
Copy link
Contributor

dsherret commented Feb 25, 2025

Describe the bug

Since #9734 (swc 1.9.3) it's no longer possible to use the resolver to figure out the scope of a declare var.

Even if this was intentional, it seems inconsistent with declare function which still has the correct scope set?

Input code

// file.d.ts
export class Test { // ctxt: 2
  method(): typeof publicVar;
}

declare function random(): number; // ctxt: 2
export declare var publicVar: number; // ctxt: 0 (previously 2 as well)

Config

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.9.3&code=H4sIAAAAAAAAA0XMQQqDMBBG4X0gd%2FiX7RXqNcR9TEYqmEyYTIoi3l2lqPvvPZozi8JPrhS0VBSrNUAk%2FXJ4vT%2FQJRMPyLWfRt85aazZrLEm0NEIYajJ68gJ4lLgeCapxp5OSP%2F5RX9Ons%2FNdnIgB2WCAAAA&config=H4sIAAAAAAAAA1WQvW7DMAyE9z6FoTmoCw8ZsrbIlilPQCh0w0J%2FICkgRuB3jyTHcbqJ3%2FF04N0%2Fus78iTWH7l6eZUjAgvyaC5EpKNwKMTolFMuU1OxWVaVKyhkbmRfBKPAvajWhDF%2FDYFbOEGSM7N8TsuAPjhTwGPnbgciR0F3k%2Be8rihGsvvkKIp8i6zlmtljDrqpJDn2P4j%2Fl2qfFstsMnIOSb7uQNXpQsuYpz%2F8ucDFK3RvBSb2tcePjJTvc6qqVLFfuzbZEgcZp9TZEclqdrav5AeQIxLB6AQAA

SWC Info output

No response

Expected behavior

Previously, the above said the scope of publicVar was the same scope as random.

Actual behavior

Now it says the ctxt of random is 2 and publicVar is 0.

Version

1.11.1

Additional context

No response

@CPunisher
Copy link
Member

Here is another same problem: #9892

@dsherret
Copy link
Contributor Author

Ah, looks like a duplicate. I'll close this one. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants