Skip to content

Typescript build error cjs #129

Closed
Closed
@BenjaminPosselt

Description

@BenjaminPosselt

I just stumbled upon a weird error:
I am currently working on a typescript project which is using socket.io in its backend. (nodejs)

When trying to build it, I got this error:

node_modules/engine.io/build/engine.io.d.ts:3:25 - error TS7016: Could not find a declaration file for module 'engine.io-parser'. 'C:/Users/Lenovo/Code/wehub_development/wehub/node_modules/engine.io-parser/build/cjs/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/engine.io-parser` if it exists or add a new declaration (.d.ts) file containing `declare module 'engine.io-parser';`

3 import * as parser from "engine.io-parser";
                          ~~~~~~~~~~~~~~~~~~

node_modules/engine.io/build/transport.d.ts:4:24 - error TS7016: Could not find a declaration file for module 'engine.io-parser'. 'C:/Users/Lenovo/Code/wehub_development/wehub/node_modules/engine.io-parser/build/cjs/index.js' implicitly has an 'any' type.
  Try `npm i --save-dev @types/engine.io-parser` if it exists or add a new declaration (.d.ts) file containing `declare module 'engine.io-parser';`

4 import { Packet } from "engine.io-parser";
                         ~~~~~~~~~~~~~~~~~~


Found 2 errors in 2 files.

Errors  Files
     1  node_modules/engine.io/build/engine.io.d.ts:3
     1  node_modules/engine.io/build/transport.d.ts:4

When i tried copying the .d.ts files in your package from the esm folder into the cjs folder, it suddenly worked without complaint.

Could it be possible that you forgot to add the .d.ts files to the cjs export of your package or are my tsconfig configurations incorrect in some way?

Thank you! :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions