GrapesJS / preset-webpage

GrapesJS Plugin Webpage Preset
http://grapesjs.com/demo.html
BSD 3-Clause "New" or "Revised" License
335 stars 291 forks source link

Got Typescript errors when building #80

Closed handhikadj closed 1 year ago

handhikadj commented 1 year ago

error message:

> grapesjs-preset-webpage@1.0.2 build
> grapesjs-cli build

Start building the library...

assets by status 10.7 KiB [cached] 1 asset

ERROR in /pathto/grapesjs-preset-webpage/src/panels.ts
./src/panels.ts 68:30-45
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/panels.ts(68,31)
      TS2554: Expected 2 arguments, but got 1.
 @ ./src/index.ts 14:0-30 43:4-10

ERROR in /pathto/grapesjs-preset-webpage/src/panels.ts
./src/panels.ts 79:30-46
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/panels.ts(79,31)
      TS2554: Expected 2 arguments, but got 1.
 @ ./src/index.ts 14:0-30 43:4-10

ERROR in /pathto/grapesjs-preset-webpage/src/panels.ts
./src/panels.ts 85:30-53
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/panels.ts(85,31)
      TS2554: Expected 2 arguments, but got 1.
 @ ./src/index.ts 14:0-30 43:4-10

ERROR in /pathto/grapesjs-preset-webpage/src/panels.ts
./src/panels.ts 91:30-53
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/panels.ts(91,31)
      TS2554: Expected 2 arguments, but got 1.
 @ ./src/index.ts 14:0-30 43:4-10

ERROR in /pathto/grapesjs-preset-webpage/src/panels.ts
./src/panels.ts 97:30-51
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/panels.ts(97,31)
      TS2554: Expected 2 arguments, but got 1.
 @ ./src/index.ts 14:0-30 43:4-10

ERROR in /pathto/grapesjs-preset-webpage/src/panels.ts
./src/panels.ts 103:30-50
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/panels.ts(103,31)
      TS2554: Expected 2 arguments, but got 1.
 @ ./src/index.ts 14:0-30 43:4-10

ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts
./src/commands/index.ts 19:4-38
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts(19,5)
      TS2345: Argument of type '{ run: (ed: any) => any; stop: () => void; }' is not assignable to parameter of type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
  Object literal may only specify known properties, and 'run' does not exist in type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
 @ ./src/index.ts 12:0-34 41:4-12

ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts
./src/commands/index.ts 19:9-11
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts(19,10)
      TS7006: Parameter 'ed' implicitly has an 'any' type.
 @ ./src/index.ts 12:0-34 41:4-12

ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts
./src/commands/index.ts 23:4-37
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts(23,5)
      TS2345: Argument of type '{ run: (ed: any) => any; stop: () => void; }' is not assignable to parameter of type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
  Object literal may only specify known properties, and 'run' does not exist in type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
 @ ./src/index.ts 12:0-34 41:4-12

ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts
./src/commands/index.ts 23:9-11
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts(23,10)
      TS7006: Parameter 'ed' implicitly has an 'any' type.
 @ ./src/index.ts 12:0-34 41:4-12

ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts
./src/commands/index.ts 27:4-46
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts(27,5)
      TS2345: Argument of type '{ run: (ed: any) => any; stop: () => void; }' is not assignable to parameter of type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
  Object literal may only specify known properties, and 'run' does not exist in type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
 @ ./src/index.ts 12:0-34 41:4-12

ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts
./src/commands/index.ts 27:9-11
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts(27,10)
      TS7006: Parameter 'ed' implicitly has an 'any' type.
 @ ./src/index.ts 12:0-34 41:4-12

ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts
./src/commands/index.ts 30:55-86
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/commands/index.ts(30,56)
      TS2554: Expected 2 arguments, but got 1.
 @ ./src/index.ts 12:0-34 41:4-12

ERROR in /pathto/grapesjs-preset-webpage/src/commands/openImport.ts
./src/commands/openImport.ts 25:11-56
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/commands/openImport.ts(25,12)
      TS2554: Expected 2 arguments, but got 1.
 @ ./src/commands/index.ts 1:0-38 6:28-38
 @ ./src/index.ts 12:0-34 41:4-12

ERROR in /pathto/grapesjs-preset-webpage/src/commands/openImport.ts
./src/commands/openImport.ts 37:4-7
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/commands/openImport.ts(37,5)
      TS2322: Type '{ run(editor: any): void; stop(): void; }' is not assignable to type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
  Object literal may only specify known properties, and 'run' does not exist in type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
 @ ./src/commands/index.ts 1:0-38 6:28-38
 @ ./src/index.ts 12:0-34 41:4-12

ERROR in /pathto/grapesjs-preset-webpage/src/commands/openImport.ts
./src/commands/openImport.ts 37:8-14
[tsl] ERROR in /pathto/grapesjs-preset-webpage/src/commands/openImport.ts(37,9)
      TS7006: Parameter 'editor' implicitly has an 'any' type.
 @ ./src/commands/index.ts 1:0-38 6:28-38
 @ ./src/index.ts 12:0-34 41:4-12

16 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.74.0 compiled with 16 errors in 1022 ms

Start building TS declaration file...
src/commands/index.ts(19,5): error TS2345: Argument of type '{ run: (ed: any) => any; stop: () => void; }' is not assignable to parameter of type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
  Object literal may only specify known properties, and 'run' does not exist in type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
src/commands/index.ts(19,10): error TS7006: Parameter 'ed' implicitly has an 'any' type.
src/commands/index.ts(23,5): error TS2345: Argument of type '{ run: (ed: any) => any; stop: () => void; }' is not assignable to parameter of type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
  Object literal may only specify known properties, and 'run' does not exist in type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
src/commands/index.ts(23,10): error TS7006: Parameter 'ed' implicitly has an 'any' type.
src/commands/index.ts(27,5): error TS2345: Argument of type '{ run: (ed: any) => any; stop: () => void; }' is not assignable to parameter of type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
  Object literal may only specify known properties, and 'run' does not exist in type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
src/commands/index.ts(27,10): error TS7006: Parameter 'ed' implicitly has an 'any' type.
src/commands/index.ts(30,56): error TS2554: Expected 2 arguments, but got 1.
src/commands/openImport.ts(25,12): error TS2554: Expected 2 arguments, but got 1.
src/commands/openImport.ts(37,5): error TS2322: Type '{ run(editor: any): void; stop(): void; }' is not assignable to type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
  Object literal may only specify known properties, and 'run' does not exist in type '(editor: Editor, sender?: any, opts?: Record<string, any> | undefined) => any'.
src/commands/openImport.ts(37,9): error TS7006: Parameter 'editor' implicitly has an 'any' type.
src/panels.ts(68,31): error TS2554: Expected 2 arguments, but got 1.
src/panels.ts(79,31): error TS2554: Expected 2 arguments, but got 1.
src/panels.ts(85,31): error TS2554: Expected 2 arguments, but got 1.
src/panels.ts(91,31): error TS2554: Expected 2 arguments, but got 1.
src/panels.ts(97,31): error TS2554: Expected 2 arguments, but got 1.
src/panels.ts(103,31): error TS2554: Expected 2 arguments, but got 1.
/pathto/grapesjs-preset-webpage/node_modules/dts-bundle-generator/dist/helpers/check-diagnostics-errors.js:21
    throw new Error(failMessage);
          ^

Error: Compiled with errors
    at checkDiagnosticsErrors (/pathto/grapesjs-preset-webpage/node_modules/dts-bundle-generator/dist/helpers/check-diagnostics-errors.js:21:11)
    at checkProgramDiagnosticsErrors (/pathto/grapesjs-preset-webpage/node_modules/dts-bundle-generator/dist/helpers/check-diagnostics-errors.js:12:5)
    at getDeclarationFiles (/pathto/grapesjs-preset-webpage/node_modules/dts-bundle-generator/dist/compile-dts.js:102:66)
    at compileDts (/pathto/grapesjs-preset-webpage/node_modules/dts-bundle-generator/dist/compile-dts.js:35:20)
    at generateDtsBundle (/pathto/grapesjs-preset-webpage/node_modules/dts-bundle-generator/dist/bundle-generator.js:27:43)
    at buildDeclaration (/pathto/grapesjs-preset-webpage/node_modules/grapesjs-cli/src/build.js:68:20)
    at /pathto/grapesjs-preset-webpage/node_modules/grapesjs-cli/src/build.js:109:19
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

steps to repro:

  1. clone
  2. run npm i
  3. run npm run build

environment: mac m1 node v16.15.1 npm 8.19.2

pieterdt commented 1 year ago

same for me, different mac (intel based) but same errors.

fujiwaratofushop commented 1 year ago

Upgrade to the latest version of grapejs and grapejs-cli.

"devDependencies": { "grapesjs": "^0.20.4", "grapesjs-cli": "^4.0.1" }

in package.json file

ktl-consulting commented 1 year ago

I updated the devDependencies and still got the same error. Node v18.14.2, npm 9.5.0. The editor.runCommand() now takes two parameters caused most of the error.