yuanqing / create-figma-plugin

:battery: The comprehensive toolkit for developing plugins and widgets for Figma and FigJam
https://yuanqing.github.io/create-figma-plugin/
MIT License
948 stars 91 forks source link

type error - Type 'Parameters<NonNullable<EventHandler>>' does not satisfy the constraint 'never[]' #227

Closed broisnischal closed 7 months ago

broisnischal commented 7 months ago

-- // type First<T extends never[]> = T[0];

++++ type First<T extends any[]> = T extends [infer F, ...any[]] ? F : never;

type FirstArgument<EventHandler extends ((...args: any) => any) | undefined> = EventHandler extends undefined ? never : First<Parameters<NonNullable>>;

node_modules>@create-figma-plugin>ui>lib>types>event-handler.d.ts

darkaico commented 7 months ago

I'm receiving the same error while running yarn run watch and also when I try to build the project yarn build

"@create-figma-plugin/ui@^3.1.0"

darkaico commented 7 months ago

@broisnischal just in case I end up skipping the lib check to avoid this error, in tsconfig.json adding skipLibCheck: true

"compilerOptions": {
    ...
    "skipLibCheck": true
  },
...
}
Jeremy-Knudsen commented 7 months ago

Getting the same error ... here to find a workaround!

image

yuanqing commented 7 months ago

Sorry for the delay folks! Life got a bit crazy so didn’t get the chance to properly look into this. The fix should be included in the next release (v3.2.0)

yuanqing commented 7 months ago

This issue should be fixed as of 3.2.0

$ npx --yes -- create-figma-plugin@3.2.0 --template plugin/preact-rectangles
info Copying "plugin/preact-rectangles" template...
info Resolving package versions...
info Installing dependencies...
success Done

First:
  cd preact-rectangles

To build the plugin:
  npm run build

To watch for code changes and rebuild the plugin automatically:
  npm run watch

$ cd preact-rectangles
$ npm run build

> build
> build-figma-plugin --typecheck --minify

info Typechecking...
success Typechecked in 0.850s
info Building...
success Built in 0.327s
darkaico commented 7 months ago

I just updated it, and everything is working perfectly! Thanks @yuanqing

Note for others: give it a try by deleting all node_modules and building from scratch, because I did the update and I was still seeing the error, but once I did the complete flush, everything works perfect