-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Cannot find name 'TransformStream' after updating to v5.2.0 #5064
Comments
I can confirm that adding |
It seems Reference: https://nodejs.org/api/webstreams.html#class-transformstream As a workaround, could you please try to update the |
@darrachequesne |
I'm using Nodejs v18.17.1, and the |
Argh, it seems the types from We could add Let me check. |
Any updates/workarounds found for this? Am still having this issue on node v18.17.0, socket.io: v4.7.2 |
why is this still not updated? even there is a simple solution(import) |
@alanpurple the problem is that adding The problem here is that the types provided by |
@darrachequesne even node 20.0 is LTS now node 16 is now end of list September 2023 |
@alanpurple I'd rather not have a new major version because the types provided by |
When compiling with TypeScript with module set to "node16" and moduleResolution to "node16", the following error would be thrown: > node_modules/engine.io-parser/build/cjs/index.d.ts:6:54 - error TS2304: Cannot find name 'TransformStream'. > 6 export declare function createPacketEncoderStream(): TransformStream<Packet, any>; > ~~~~~~~~~~~~~~~ > node_modules/engine.io-parser/build/cjs/index.d.ts:7:96 - error TS2304: Cannot find name 'TransformStream'. > 7 export declare function createPacketDecoderStream(maxPayload: number, binaryType: BinaryType): TransformStream<Uint8Array, any>; > ~~~~~~~~~~~~~~~ > Found 2 errors in the same file, starting at: node_modules/engine.io-parser/build/cjs/index.d.ts:6 This is because the TransformStream object is not exposed in the global scope in the `@types/node` package, even though it is since Node.js `v18.0.0`. Reference: https://nodejs.org/api/webstreams.html#class-transformstream Note: we only import the TransformStream type (not value) because it isn't defined on older Node.js versions. Related: - https://github.com/socketio/engine.io-parser/issues/136 - socketio/socket.io-client#1606
I think I have found a workaround, which does not break older Node.js versions: socketio/engine.io-parser@0305b4a Could you please check? Fiddle: https://github.com/socketio/socket.io-fiddle/tree/typescript-node16 |
Hi there, Fast question, what about CI/CD pipelines that use node? Our pipeline continues to fail the build process for our UI repo even with the suggested fix and we have updated the pipeline to use node v16 (previously v14). |
@kn1ghtm0nster which version of |
unfortunately, I can't provide examples for reproducing the build failure on the CI/CD config (it's kept behind a very secret vault away from developers at my company for some reason) however, the version of // package.json (angular)
{"dependencies" : {
// ... other dependencies
"socket.io-client" : "4.5.2" // was previously "socket.io-client" : "^4.5.2"
}
} |
@kn1ghtm0nster this does indeed help! This is indeed a breaking change for older versions of That being said, is there any particular reason you are still using version |
That's a great question and unfortunately one I cannot answer since I joined the team long after the UI codebase was established. Ultimately the short answer is the packages are not being updated regularly (mainly because the company limits the access to the outside |
Not sure if I understand you completely, but does this mean that this version (5.2.2) won't be possible to use with Node < 16? If it helps, I am currently using Node 14.21.3, and I'm facing the same issue. While moving up Node versions is the plan in the future, I am trying to see if I can fix this temporarily (since priorities in my company lie elsewhere right now 😄). Thanks for your time! |
It does work with Node.js 16 (down to Node.js 10.2.0 actually), but the TypeScript compiler will report an error if As a workaround, one can either:
|
Thanks for the response, I was inkling towards option 1 anyway, but I wasn't sure how it would work. Tried it out, seems to work fine now! |
The latest change messes up typing for client libraries as the new import introduced here: socketio/engine.io-parser@0305b4a in tsconfig.json we specify that we do not want any node types: {
"compilerOptions": {
"lib": ["ESNext", "DOM"],
"types": [],
},
} the following code fails to typecheck if import {} from 'engine.io-parser';
type Equals<X, Y> =
(<T>() => T extends X ? 1 : 2) extends
(<T>() => T extends Y ? 1 : 2) ? true : false;
type TimeoutReturnType = ReturnType<typeof setTimeout>;
type TimeoutReturnTypeCheck = Equals<TimeoutReturnType, number>;
export const test: TimeoutReturnTypeCheck = true; removing the first line fixes the issue, this effects downstream so importing |
upgrading @types/node to v20.11.30 fix for me |
The previous commit [1] tried to work around the fact that the TransformStream object is not exposed in the global scope in the `@types/node` package, even though it is since Node.js `v18.0.0`. Unfortunately, it created two new issues: - using an older `@types/node` version (before v16) would fail with: > error TS2307: Cannot find module 'node:stream/web' or its corresponding type declarations. Related: #5064 (comment) - browser-only environments would somehow include the node types, leading to conflicts like the return value of the setTimeout() method Related: - #5064 (comment) - #5065 [1]: socketio/engine.io-parser@0305b4a
@darrachequesne I tested it, and it works :) |
@Sekkmer awesome, thanks of the update 👍 I think this can be closed now. |
Since I updated
socket.io
from thev4.7.1
to thev4.7.2
(and soengine.io-parser
from thev5.1.0
to thev5.2.1
), I'm getting the following errors while building my projects:Funnily, I'm only getting this error when compiling using
tsc
but not when compiling usingesbuild
.npx tsc
-> errornpx esbuild src/index.ts --platform=node
-> okHere is my
tsconfig.json
:Reading nodejs's documentation, when using
TransformStream
, it looks like they are importing it withwhich is not the case for
engine.io-parser
, so maybe that's the problem.The text was updated successfully, but these errors were encountered: