gjsify / ts-for-gir

TypeScript type definition generator for GObject introspection interfaces
https://gjsify.org/pages/projects
Apache License 2.0
237 stars 18 forks source link

tsc report Duplicate identifier #157

Closed Sherlock-Holo closed 6 months ago

Sherlock-Holo commented 6 months ago

I am a newbie in GNOME extension, I follow https://gjs.guide/extensions/development/typescript.html to create a ts GNOME extension project, everything is good except when I call make, it will report error

node_modules/.pnpm/@girs+atk-1.0@2.50.0-3.2.7/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:4:20 - error TS2300: Duplicate identifier 'Atk10'.

4     export default Atk10;
                     ~~~~~

  node_modules/.pnpm/@girs+atk-1.0@2.50.1-3.2.9/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:4:20
    4     export default Atk10;
                         ~~~~~
    'Atk10' was also declared here.
  node_modules/.pnpm/@girs+atk-1.0@2.50.1-3.2.9/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:9:20
    9     export default Atk10;
                         ~~~~~
    and here.

node_modules/.pnpm/@girs+atk-1.0@2.50.0-3.2.7/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:9:20 - error TS2300: Duplicate identifier 'Atk10'.

9     export default Atk10;
                     ~~~~~

  node_modules/.pnpm/@girs+atk-1.0@2.50.1-3.2.9/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:4:20
    4     export default Atk10;
                         ~~~~~
    'Atk10' was also declared here.
  node_modules/.pnpm/@girs+atk-1.0@2.50.1-3.2.9/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:9:20
    9     export default Atk10;
                         ~~~~~
    and here.

node_modules/.pnpm/@girs+atk-1.0@2.50.0-3.2.7/node_modules/@girs/atk-1.0/atk-1.0-import.d.ts:6:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'Atk' must be of type 'typeof Atk', but here has type 'typeof Atk'.

6         Atk: typeof Atk10;
          ~~~

  node_modules/.pnpm/@girs+atk-1.0@2.50.1-3.2.9/node_modules/@girs/atk-1.0/atk-1.0-import.d.ts:6:9
    6         Atk: typeof Atk10;
              ~~~
    'Atk' was also declared here.

node_modules/.pnpm/@girs+atk-1.0@2.50.1-3.2.9/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:4:20 - error TS2300: Duplicate identifier 'Atk10'.

4     export default Atk10;
                     ~~~~~

  node_modules/.pnpm/@girs+atk-1.0@2.50.0-3.2.7/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:4:20
    4     export default Atk10;
                         ~~~~~
    'Atk10' was also declared here.
  node_modules/.pnpm/@girs+atk-1.0@2.50.0-3.2.7/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:9:20
    9     export default Atk10;
                         ~~~~~
    and here.

node_modules/.pnpm/@girs+atk-1.0@2.50.1-3.2.9/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:9:20 - error TS2300: Duplicate identifier 'Atk10'.

9     export default Atk10;
                     ~~~~~

  node_modules/.pnpm/@girs+atk-1.0@2.50.0-3.2.7/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:4:20
    4     export default Atk10;
                         ~~~~~
    'Atk10' was also declared here.
  node_modules/.pnpm/@girs+atk-1.0@2.50.0-3.2.7/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:9:20
    9     export default Atk10;
                         ~~~~~
    and here.

node_modules/.pnpm/@girs+gnome-shell@45.0.0-beta9/node_modules/@girs/gnome-shell/dist/ui/dialog.d.ts:69:12 - error TS2416: Property '_init' in type 'ListSectionItem' is not assignable to the same property in base type 'BoxLayout'.
  Type '(params: { style_class?: string | null | undefined; }) => void' is not assignable to type '(config?: ConstructorProperties | undefined) => void'.
    Types of parameters 'params' and 'config' are incompatible.
      Type 'ConstructorProperties | undefined' is not assignable to type '{ style_class?: string | null | undefined; }'.
        Type 'undefined' is not assignable to type '{ style_class?: string | null | undefined; }'.

69     public _init(params: { style_class?: string | null }): void;
              ~~~~~

node_modules/.pnpm/@girs+gnome-shell@45.0.0-beta9/node_modules/@girs/gnome-shell/dist/ui/panelMenu.d.ts:19:5 - error TS2416: Property '_init' in type 'ButtonBox' is not assignable to the same property in base type 'Widget'.
  Type '(params: ConstructorProperties) => void' is not assignable to type '(config?: ConstructorProperties | undefined) => void'.
    Types of parameters 'params' and 'config' are incompatible.
      Type 'ConstructorProperties | undefined' is not assignable to type 'ConstructorProperties'.
        Type 'undefined' is not assignable to type 'ConstructorProperties'.

19     _init(params: ButtonBox.ConstructorProperties): void;
       ~~~~~

Found 7 errors in 5 files.

Errors  Files
     2  node_modules/.pnpm/@girs+atk-1.0@2.50.0-3.2.7/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:4
     1  node_modules/.pnpm/@girs+atk-1.0@2.50.0-3.2.7/node_modules/@girs/atk-1.0/atk-1.0-import.d.ts:6
     2  node_modules/.pnpm/@girs+atk-1.0@2.50.1-3.2.9/node_modules/@girs/atk-1.0/atk-1.0-ambient.d.ts:4
     1  node_modules/.pnpm/@girs+gnome-shell@45.0.0-beta9/node_modules/@girs/gnome-shell/dist/ui/dialog.d.ts:69
     1  node_modules/.pnpm/@girs+gnome-shell@45.0.0-beta9/node_modules/@girs/gnome-shell/dist/ui/panelMenu.d.ts:19
make: *** [Makefile:13:dist/extension.js] 错误 2

however tsc still generated the extension.js and prefs.js

I tried npm and pnpm, both of them report error, I am not sure what cause this problem

JumpLink commented 6 months ago

@Sherlock-Holo Looks like you have different Gir type versions installed and therefore duplicate types. Can you show your package.json here?

Sherlock-Holo commented 6 months ago

I recreate a project, the problem gone, I don't know why but problem not exist now 🙈