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

fix(types): explicitly set Vite hooks' this to void #9885

Merged
merged 1 commit into from Aug 29, 2022

Conversation

antfu
Copy link
Member

@antfu antfu commented Aug 28, 2022

Description

With the object hooks introduced, plugins should not rely on the implicit this from the plugin object for Vite custom plugins. This PR explicitly set them to void to provide early TypeScript hints.

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.

Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

I think this is needed now, so we are later able to add a context-like object as Rollup has for some of their hooks. Plugins authors may already have to review their plugins after 3.1 because of the types updates in rollup, so I think we should include it now. Let's merge it and release it in beta.1 so we give a few days to the ecosystem to test.

@patak-dev patak-dev merged commit 2d2f2e5 into main Aug 29, 2022
@patak-dev patak-dev deleted the fix/types-this-void branch August 29, 2022 11:15
@aleclarson
Copy link
Member

This breakage seems premature. Why don't we bind the plugin object to config and configResolved until we have an actual use case for a Vite-specific this context?

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.

None yet

3 participants