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

chore: init imports var before use #9569

Merged
merged 1 commit into from
Aug 7, 2022
Merged

Conversation

poyoho
Copy link
Member

@poyoho poyoho commented Aug 7, 2022

Description

Additional context


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

let imports: ImportSpecifier[]
let imports: ImportSpecifier[] = []
Copy link
Member

Choose a reason for hiding this comment

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

Not sure if we need this since the catch block below would throw an error before something else uses imports. Though we did do something like this in the code above 🤔

let imports: readonly ImportSpecifier[] = []
try {
imports = parseImports(source)[0]
} catch (e: any) {
this.error(e, e.idx)
}

Copy link
Member Author

Choose a reason for hiding this comment

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

if no init the variable, vscode will throw an error.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah this seems to be similar to #9015. I'd actually be fine to merge this anyway with the same reason as that PR.

@bluwy bluwy changed the title fix: use var before init chore: init imports var before use Aug 7, 2022
@bluwy bluwy merged commit 905b8eb into vitejs:main Aug 7, 2022
@poyoho poyoho deleted the typo/init-let branch August 7, 2022 07:56
@poyoho poyoho mentioned this pull request Sep 26, 2022
9 tasks
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