PupilTong / node-tuntap2

a opensource, asynchronized, napi-based, business friendly tuntap device addon for nodejs.
Apache License 2.0
12 stars 5 forks source link

Class 'Tuntap' incorrectly implements interface 'TuntapI' #16

Open stefanwerfling opened 3 months ago

stefanwerfling commented 3 months ago

With the update to the latest 18.x version of nodejs ("@types/node": "^18.19.33",) there were many new methods in the interface. Could you clarify this issue?

3.066   SOLINK_MODULE(target) Release/obj.target/tuntap2Addon.node
3.170   COPY Release/tuntap2Addon.node
3.175 make: Leaving directory '/opt/flyingfish/node_modules/tuntap2/build'
3.177 gyp info ok 
8.059 src/ts/Tuntap.ts(4,14): error TS2420: Class 'Tuntap' incorrectly implements interface 'TuntapI'.
8.059   Type 'Tuntap' is missing the following properties from type 'TuntapI': iterator, map, filter, forEach, and 10 more.

image

These come from the duplex interface: export interface TuntapI extends Duplex

stefanwerfling commented 1 month ago

@PupilTong Do you perhaps have a suggestion? Could you leave out "extends Duplex"? What did you think?

PupilTong commented 1 month ago

@PupilTong Do you perhaps have a suggestion? Could you leave out "extends Duplex"? What did you think?

Could u please inspect which interface requires these implementation? Thank!

stefanwerfling commented 1 month ago

Hello @PupilTong, with package.json:

"devDependencies": {
    "@types/jmespath": "^0.15.0",
    "@types/mocha": "^10.0.1",
    "@types/node": "^20.14.10",
    "coverage-badge-creator": "^1.0.18",
    "inet_xtoy": "^1.2.5",
    "mocha": "^10.2.0",
    "nyc": "^15.1.0",
    "should": "^13.2.3",
    "typescript": "^5.2.2"
  },

become: image

....

Now i check the types: image

The "ReadableBase" has more implemented methods. I can all implement with an Exception.

What did you think?

Next problem, i add the method:

public asIndexedPairs(options?: Pick<ArrayOptions, "signal">): Readable {
        return undefined;
    }

ArrayOptions is unknow and has none export by stream.d.ts ....

It seems to me that the types are faulty. But I can't judge that because I haven't found an example that extends "Duplex".

I have now written "// @ts-ignore" at the top of the class.

stefanwerfling commented 1 month ago

With the "// @ts-ignore export class Tuntap extends TuntapBase implements TuntapI {"

I can perform my deployment again.