-
Notifications
You must be signed in to change notification settings - Fork 5
allow var in TypeScript ambient declarations #68
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
Conversation
🦋 Changeset detectedLatest commit: b2b469c The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Package Changes Through b2b469cNo changes. Add a change file through the GitHub UI by following this link. Read about change files or the docs at github.com/jbolda/covector |
cowboyd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me.
|
Thanks! Could you publish release? |
|
@jbolda For some reason, this didn't open up a release PR. Any idea why? https://github.com/thefrontside/javascript/actions/runs/20697051068
|
|
@cowboyd Perhaps a changeset should have been added? |
|
@cowboyd the workflows have covector which looks for change files in the |
|
@azat-io looks like I put the changes in the wrong dir! I don't currently have a checkout of this repo, would you mind moving it to the Also, @jbolda we will probably need to set this repo up with OIDC publishing, which I can do now. Were there some changes we needed to make to the publish action itself? |
|
@cowboyd just removing the token. |
|
Do I need to do something, or will you publish it? |
|
Actually, I have some more time today, so I can take care of it. |
|
This should be available now #69 |
|
Thanks! |
Motivation
The
prefer-letrule was incorrectly flaggingvardeclarations in TypeScript ambient contexts (declare global,declare module,declare namespace). In these contexts,varhas special semantic meaning - it creates properties on the global object (e.g.,window.fathom), whileletwould create lexical bindings that aren't accessible as properties.This was forcing developers to add
eslint-disablecomments for legitimate TypeScript code:Approach
Added a new helper function
isInAmbientContext()that walks up the AST tree to check if a variable declaration is inside a TSModuleDeclaration with declare: true. When var is detected in an ambient context, the rule now skips it instead of reporting an error.