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

Typescript compilation error: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier. #87

Closed AndrewGrachov closed 4 years ago

AndrewGrachov commented 4 years ago
$ tsc && cp -r src/api dist/api
node_modules/scramjet/.d.ts/index.d.ts:8:1 - error TS1046: Top-level declarations in .d.ts files must start with either a 'declare' or 'export' modifier.

8 function pipelineOverride(...a: never[]): never;
  ~~~~~~~~

node_modules/scramjet/.d.ts/index.d.ts:13:7 - error TS2417: Class static side 'typeof PromiseTransform' incorrectly extends base class static side 'typeof Transform'.
  The types of 'pipeline.__promisify__' are incompatible between these types.
    Type '(...a: never[]) => never' is not assignable to type '{ (stream1: ReadableStream, stream2: WritableStream): Promise<void>; (stream1: ReadableStream, stream2: ReadWriteStream, stream3: WritableStream): Promise<...>; (stream1: ReadableStream, stream2: ReadWriteStream, stream3: ReadWriteStream, stream4: WritableStream): Promise<...>; (stream1: ReadableStream, stream2: Rea...'.
      Types of parameters 'a' and 'stream1' are incompatible.
        Type 'ReadableStream' is not assignable to type 'never'.

TS version: 3.8.3

Scramjet version: 4.33.4

Solution:

downgraded to 4.30.1

MichalCz commented 4 years ago

Hey, thanks for the comment, we're on it. :)

MichalCz commented 4 years ago

@AndrewGrachov can you extract a simple repo for instance with a single file that causes the above issue? We'd check if we can reproduce this.

Or at least share the code that uses scramjet?

AndrewGrachov commented 4 years ago

https://github.com/AndrewGrachov/scramjet-error

here you are, I suspect yarn

AndrewGrachov commented 4 years ago

dockerfile build should fail

MichalCz commented 4 years ago

Thanks, I'll check - I believe I'll need to redo the pipeline method override in all streams - I don't know why it's like that in ts since pipeline is not a method of Readable or Writable or any other Node.js stream, but worst case scenario I'll just allow any there...

MichalCz commented 4 years ago

I'm trying to fix this - but this is taking some extra time, as I don't really know how to make Typescript ok with overriding of some of Duplex/PassThrough stream methods (pipeline mostly).

I'll try to solve it in such a way that this will be compatible - I'll create a PR over the weekend and perhaps you could help me with getting the definitions right.

MichalCz commented 4 years ago

Still working on this - it's a bit annoying since I added the pipeline method before it was added to Transform stream and then the method was made incompatible which doesn't go well with Typescript.

MichalCz commented 4 years ago

Another update - we're focusing on Scramjet v5.x branch now, as we're trying to pass a tipping point there - still we'll return to this asap.

MichalCz commented 4 years ago

Ok, fix underway - I needed to remove the pipe method altogether and use node's own one. There's a possible compatibility issue, but if that occurs for anyone - it's most likely to be a bug (so you'd need to fix that in your own code).

@AndrewGrachov tell me if it's now working for you with 4.34.0 - I'll publish this in a couple minutes.

MichalCz commented 4 years ago

@AndrewGrachov shall we close this?

AndrewGrachov commented 4 years ago

Build is ok, thank you!

MichalCz commented 4 years ago

Brilliant. šŸ‘