Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error TS2304: Cannot find name 'StringDecoder'. with v6.6.1 #1008

Closed
anthonylau opened this issue Nov 27, 2019 · 8 comments
Closed

error TS2304: Cannot find name 'StringDecoder'. with v6.6.1 #1008

anthonylau opened this issue Nov 27, 2019 · 8 comments

Comments

@anthonylau
Copy link

When I compile my project,

../../node_modules/@types/readable-stream/index.d.ts:138:18 - error TS2304: Cannot find name 'StringDecoder'.

138         decoder: StringDecoder | null;
                     ~~~~~~~~~~~~~

Node: 10.16.0
Typescript: 3.3.3333
tedious: 6.6.1

It works if I change tedious version to 6.5.0.
Not sure if this is related to #1007

Would anyone advise?

@MichaelSun90
Copy link
Contributor

Hi @anthonylau, can you provide some details on how did you compile your project or maybe provide a reproduce script? I have set up the tedious project with the versions that you provide, and the tedious project builds fine. Also, do you want to try your project with a newer version of Typescript since that 3.3.3333 is released about 9 months ago?

@obermobber
Copy link

obermobber commented Dec 12, 2019

Hey @MichaelSun90, I have the same issue as @anthonylau was having. I also fixed it with going for tedious v6.5.0.

running my start scrip ("start": "nodemon --exec ts-node -- ./src/index.ts") does not cause any problems, but running a prod build ("tsc -p tsconfig.json") caused the following error:

node_modules/@types/readable-stream/index.d.ts:138:18 - error TS2304: Cannot find name 'StringDecoder'.

138 decoder: StringDecoder | null;
~~~~~~~~~~~~~

Found 1 error.

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! petrofer-pcloud@1.0.6-1 build:prod: tsc -p tsconfig.json
npm ERR! Exit status 2

I use it in combination with
sequelize 5.15.1
typescript: 3.3.4000
Node: 10.15.3

What additional information do you need?

@obermobber
Copy link

additonal info:
going into the index.d.ts, typescript is giving the following problem information:
'StringDecoder' refers to a value, but is being used as a type here. (ts2749)

@arthurschreiber
Copy link
Collaborator

I've trouble understanding where this issue is coming from -- based on https://github.com/DefinitelyTyped/DefinitelyTyped/blob/6a3064cc7408b4e71d0d0feb6f92457d4c22e15c/types/readable-stream/index.d.ts#L132, there is no reference to StringDecoder but NodeStringDecoder.

Can you check the contents of the node_modules/@types/readable-stream/index.d.ts file on your system?

@obermobber
Copy link

obermobber commented Dec 12, 2019

Yeah I checked, and the ReadableState interface looks as follows:

interface ReadableState {
        objectMode: boolean;
        highWaterMark: number;
        buffer: BufferList<any>;
        length: number;
        pipes: any; // NodeJS.WritableStream | any[]; // TODO
        pipesCount: number;
        flowing: any;
        ended: boolean;
        endEmitted: boolean;
        reading: boolean;
        sync: boolean;
        needReadable: boolean;
        emittedReadable: boolean;
        readableListening: boolean;
        resumeScheduled: boolean;
        destroyed: boolean;
        awaitDrain: number;
        defaultEncoding: string;
        readingMore: boolean;
        decoder: StringDecoder | null;
        encoding: string | null;

        // new (options: ReadableStateOptions, stream: _Readable): ReadableState;
    }

This is the tedious dependency that it has installed:

"readable-stream": {
          "version": "3.4.0",
          "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.4.0.tgz",
          "integrity": "sha512-jItXPLmrSR8jmTRmRWJXCnGJsfy85mB3Wd/uINMXA65yrnFo0cPClFIUWzo2najVNSl+mx7/4W8ttlLWJe99pQ==",
          "requires": {
            "inherits": "^2.0.3",
            "string_decoder": "^1.1.1",
            "util-deprecate": "^1.0.1"
          }

@IanChokS
Copy link
Member

IanChokS commented Dec 12, 2019

image

So it looks like readable-stream v 2.3.6 has been merged with NodeStringDecoder instead of StringDecoder, however, it might have not been published yet

image

image

This is probably a DefinitelyTyped problem

This is the tedious dependency that it has installed:

I think you're looking at the wrong readable-stream dependency. The problem lies in @Types/readable-dependency, which should have 2.3.5 installed

image

@IanChokS
Copy link
Member

IanChokS commented Dec 12, 2019

An issue about this has already been raised DefinitelyTyped/DefinitelyTyped#37869

Here's the fix: @anthonylau @obermobber . Hopefully this also fixes your issue!
image

@obermobber
Copy link

obermobber commented Dec 12, 2019

Yeah, was just going to write that!
I installed @types/node: 12.12.17 and the prod build works fine. Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants