rotemdan / lzutf8.js

A high-performance Javascript string compression library
MIT License
322 stars 26 forks source link

Typescript errors from new release #18

Closed maximelkin closed 6 years ago

maximelkin commented 6 years ago

node_modules/lzutf8/build/production/lzutf8.d.ts:18:43 - error TS2503: Cannot find namespace 'stream'.

18 static createCompressionStream(): stream.Transform;


node_modules/lzutf8/build/production/lzutf8.d.ts:24:45 - error TS2503: Cannot find namespace 'stream'.

24         static createDecompressionStream(): stream.Transform;

node_modules/lzutf8/build/production/lzutf8.d.ts:280:41 - error TS2503: Cannot find namespace 'stream'.

280 function createCompressionStream(): stream.Transform;


node_modules/lzutf8/build/production/lzutf8.d.ts:281:43 - error TS2503: Cannot find namespace 'stream'.

281     function createDecompressionStream(): stream.Transform;
rotemdan commented 6 years ago

Thanks for the report. I'm aware and working on the issue (I mentioned it in #14) . Seems like the generated declaration file has unresolvable types stream and Buffer. I guess one hack to overcome this is to append:

declare namespace LZUTF8 {
    type Buffer = any;

    namespace stream {
        type Transform = any;
    }
}

to the generated d.ts file during the build process. Another option is to maintain the file manually, but I prefer it to be automated. Please let me know if you know of better alternatives? (I wish there was a feature that does the cast to any in the TS compiler but I couldn't find anything like this).

rotemdan commented 6 years ago

I went with this solution, for now, and pushed it to npm (version 0.5.3).