Xetera / ghost-cursor

🖱️ Generate human-like mouse movements with puppeteer or on any 2D plane
MIT License
1.09k stars 118 forks source link

Puppeteer Types Conflict #33

Closed ghost closed 3 years ago

ghost commented 3 years ago

Puppeteer started to ship .d.ts files in npm package since February. The DefinitelyTyped package is no longer accurate, I believe. I'm getting the below errors during compilations with "ghost-cursor": "^1.1.5" and "puppeteer": "^10.1.0" installed.

node_modules/ghost-cursor/lib/spoof.d.ts:22:9 - error TS2687: All declarations of '_client' must have identical modifiers.

22         _client: {
           ~~~~~~~

node_modules/ghost-cursor/lib/spoof.d.ts:22:9 - error TS2717: Subsequent property declarations must have the same type.  Property '_client' must be of type 'any', but here has type '{ send: (name: string, params: {}) => Promise<any>; }'.

22         _client: {
           ~~~~~~~

  node_modules/puppeteer/lib/types.d.ts:3855:13
    3855     private _client;
                     ~~~~~~~
    '_client' was also declared here.

node_modules/ghost-cursor/lib/spoof.d.ts:29:15 - error TS2430: Interface 'ElementHandle<ElementType>' incorrectly extends interface 'JSHandle<ElementType>'.

29     interface ElementHandle {
                 ~~~~~~~~~~~~~

node_modules/ghost-cursor/lib/spoof.d.ts:35:9 - error TS2717: Subsequent property declarations must have the same type.  Property 'frame' must be of type '() => Frame | null', but here has type '() => Frame'.      

35         frame: () => Frame;
           ~~~~~

  node_modules/puppeteer/lib/types.d.ts:1803:5
    1803     frame(): Frame | null;
             ~~~~~
    'frame' was also declared here.

node_modules/puppeteer/lib/types.d.ts:1434:22 - error TS2415: Class 'ElementHandle<ElementType>' incorrectly extends base class 'JSHandle<ElementType>'.
  Types of property '_remoteObject' are incompatible.
    Property 'type' is missing in type '{ objectId: string; }' but required in type 'RemoteObject'.

1434 export declare class ElementHandle<ElementType extends Element = Element> extends JSHandle<ElementType> {
                          ~~~~~~~~~~~~~

  node_modules/puppeteer/lib/types.d.ts:7399:13
    7399             type: ('object' | 'function' | 'undefined' | 'string' | 'number' | 'boolean' | 'symbol' | 'bigint');
                     ~~~~
    'type' is declared here.

node_modules/puppeteer/lib/types.d.ts:3855:13 - error TS2687: All declarations of '_client' must have identical modifiers.

3855     private _client;
                 ~~~~~~~

Found 6 errors.
Niek commented 3 years ago

The types in Puppeteer are really messed up since they started shipping themselves. See for example: https://github.com/puppeteer/puppeteer/issues/6979

I'll see if we can switch the types to puppeteer@10 though.

Xetera commented 3 years ago

I think puppeteer needs to be marked as a peerDependency in this case. Not sure why I didn't do that in the first release.

Niek commented 3 years ago

If you use a peerDependency you can't use the types in that package, because it doesn't install it AFAIK. So you really need the whole puppeteer package as a devDependency 😞

Niek commented 3 years ago

This should be fixed in https://github.com/Xetera/ghost-cursor/commit/4dd885815bcc229599f6608fef27e50352062b96

Can you please check @ItzRabbs by installing the master version?

ghost commented 3 years ago

Works great. Thank you for the quick turnaround.

Niek commented 3 years ago

Published as v1.1.6: https://www.npmjs.com/package/ghost-cursor/v/1.1.6