scramjetorg / scramjet

Public tracker for Scramjet Cloud Platform, a platform that bring data from many environments together.
https://www.scramjet.org
MIT License
253 stars 20 forks source link

Class 'PromiseTransform' incorrectly implements class 'Readable' #112

Closed upsetbit closed 2 years ago

upsetbit commented 2 years ago

Thank you for this great project and for releasing it under an open source license!

Describe the bug Typescript reports the following typing error when building:

node_modules/scramjet/.d.ts/index.d.ts:9:15 - error TS2720: Class 'PromiseTransform' incorrectly implements class 'Readable'. Did you mean to extend 'Readable' and inherit its members as a subclass?
  Type 'PromiseTransform' is missing the following properties from type 'Readable': readableAborted, readableDidRead

9 declare class PromiseTransform implements Readable, Writable {

To Reproduce Steps to reproduce the behavior:

  1. Create a new directory, init npm and install basic dependencies npm i --save-dev typescript @types/node scramjet

  2. Create a tsc config file

    {
    "compilerOptions": {
    "lib": ["ES2020", "ES2021"],
    "target": "ES2018",
    "module": "commonjs",
    "rootDir": "./",
    "outDir": "./dist",
    "strict": true,
    "alwaysStrict": true,
    "removeComments": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "esModuleInterop": true,
    "pretty": true
    },
    "exclude": [
    "node_modules",
    "dist"
    ]
    }
  3. Create a simple file that uses scramjet

    
    import { StringStream } from 'scramjet'

StringStream .fromString('hello world', 'utf-8') .lines(' ') .toArray() .then((t) => console.log(t.join(' ')))



4. Compile with `npx tsc`

5. See error

**System:**
 - OS: MacOS 12.0.1
 - Node version: 17.0.1
 - Scramjet Version: 4.36.0

**Additional context**
I've notice that this problem occurs when `@types/node > 15.6.1` (latest is `16.11.7`).
MichalCz commented 2 years ago

Hi @upsetbit,

I'll check it shortly. I had some problems building the code lately so this may be connected.

MichalCz commented 2 years ago

Ok, there is a simple fix - the Readable interface has changed. This should be fixed today.

MichalCz commented 2 years ago

Hey @upsetbit - please check if this now works.

Here's the code you proposed as a test - it should be working: https://github.com/scramjetorg/scramjet/tree/develop/test/ts-test

I published the changes to NPM just now.

MichalCz commented 2 years ago

Actually the new version is 4.36.1 and has been published just now. Let me know if this helped.

upsetbit commented 2 years ago

@MichalCz thank you for this quick fix. I've tested scramjet==4.36.1 alongside @types/node==16.11.8 and saw no problem. You can close this issue.

MichalCz commented 2 years ago

Fantastic. :)

We'll be releasing a new version of Scramjet's core framework with a new engine and two new programming languages early next year so if you like this, I'd recommend subscribing to our repo and perhaps you could also push the star button. :)

But our work here is done. :)