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
902 stars 85 forks source link

Error: Can't build `plugin/preact-rectangles` or `plugin/preact-resizable` templates #226

Closed jacktowery closed 3 months ago

jacktowery commented 4 months ago

I'm getting a TypeScript error when trying to build the plugin/preact-rectangles or plugin/preact-resizable templates for the first time:

$ npm run build

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

info Typechecking...
error TypeScript error

    node_modules/@create-figma-plugin/ui/lib/types/event-handler.d.ts:3:86 - error TS2344: Type 'Parameters<NonNullable<EventHandler>>' does not satisfy the constraint 'never[]'.
      Type 'any[]' is not assignable to type 'never[]'.
        Type 'any' is not assignable to type 'never'.

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

Steps to reproduce (following the Quick Start guide):

  1. $ npx --yes create-figma-plugin
  2. Select plugin/preact-rectangles or plugin/preact-resizable
  3. $ cd preact-rectangles
  4. $ npm run build
  5. TypeScript error

The same error occurs when attempting to add @create-figma-plugin/ui to an existing plugin following the instructions on the documentation website.

artemartemov commented 4 months ago

same issue here

thevarunkhatri commented 4 months ago

Having the same issue. Did some tinkering and it appears the problem is Typescript 5.4. Installing typescript 5.3 instead fixed it for me.

plcdnl commented 4 months ago

Same error https://github.com/yuanqing/create-figma-plugin/issues/227

darkaico commented 3 months ago

I ended up skipping the lib check to avoid this error, in tsconfig.json adding skipLibCheck: true

"compilerOptions": {
    ...
    "skipLibCheck": true
  },
...
}
yuanqing commented 3 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