Skip to content

Plugin type tweaks#706

Open
mrginglymus wants to merge 2 commits intoterrazzoapp:mainfrom
mrginglymus:plugin-type-tweaks
Open

Plugin type tweaks#706
mrginglymus wants to merge 2 commits intoterrazzoapp:mainfrom
mrginglymus:plugin-type-tweaks

Conversation

@mrginglymus
Copy link
Copy Markdown
Contributor

Changes

  1. Marks get/set transforms as having this: void.
  2. Allow non-async transform/build/buildEnd hooks

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Mar 24, 2026

⚠️ No Changeset found

Latest commit: 5218141

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@drwpow
Copy link
Copy Markdown
Collaborator

drwpow commented Apr 24, 2026

Sorry, I think this PR was opened while I was away and this slipped off my radar.

I’m on board with improving the overall types but could you provide a little more detail on the error this addresses? Does this occur when declaring plugins in .ts format? With which TS version? etc. etc.

I‘d just like to test this to make sure these changes don’t cause other TS issues for other folks, is all

@mrginglymus
Copy link
Copy Markdown
Contributor Author

Sorry for the lack of detail! Without this, accessing the setTransform method in a custom plugin causes a @typescript-eslint/unbound-method error:

export default defineConfig({
  plugins: [
    {
      transform({ resolver, tokens, setTransform }) {

with the suggestion

If a function does not access this, it can be annotated with this: void.

The adding of void | Promise<void> is to allow for methods that don't have await calls without having to suppress @typescript-eslint/require-await - although arguably @typescript-eslint should be able to detect that the function is being passed to something that only accepts awaitable functions.

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