Cannot find name 'ReadableStream' when trying to build via Typescript
akirilyuk opened this issue · comments
Description
- Node.js version: 18.17.0
- Gitbeaker version: 39.26.2
- Gitbeaker release (cli, node, browser, core, requester-utils): rest
- OS & version:
"ts-node": "10.9.1",
"tsc-watch": "6.0.4",
"typescript": "5.1.6"
yarn run v1.22.19
$ tsc --project tsconfig.json
node_modules/@gitbeaker/core/dist/index.d.ts:6266:60 - error TS2304: Cannot find name 'ReadableStream'.
6266 } & Sudo & ShowExpanded<E>): Promise<GitlabAPIResponse<ReadableStream, void, E, void>>;
~~~~~~~~~~~~~~
node_modules/@gitbeaker/core/dist/index.d.ts:6891:60 - error TS2304: Cannot find name 'ReadableStream'.
6891 } & Sudo & ShowExpanded<E>): Promise<GitlabAPIResponse<ReadableStream, void, E, void>>;
~~~~~~~~~~~~~~
node_modules/@gitbeaker/core/dist/index.d.ts:7422:60 - error TS2304: Cannot find name 'ReadableStream'.
7422 } & Sudo & ShowExpanded<E>): Promise<GitlabAPIResponse<ReadableStream, void, E, void>>;
~~~~~~~~~~~~~~
node_modules/@gitbeaker/core/dist/index.d.ts:7543:101 - error TS2304: Cannot find name 'ReadableStream'.
7543 sync(groupId: string | number, options?: Sudo & ShowExpanded): Promise<string | number | void | ReadableStream<any> | Blob | string[] | CamelizedResponse<Record<string, unknown>, C> | CamelizedResponse<Record<string, unknown>, C>[] | null>;
~~~~~~~~~~~~~~
node_modules/@gitbeaker/requester-utils/dist/index.d.ts:11:80 - error TS2304: Cannot find name 'ReadableStream'.
11 type ResponseBodyTypes = Record<string, unknown> | Record<string, unknown>[] | ReadableStream | Blob | string | string[] | number | void | null;
~~~~~~~~~~~~~~
Found 5 errors in 2 files.
Errors Files
4 node_modules/@gitbeaker/core/dist/index.d.ts:6266
1 node_modules/@gitbeaker/requester-utils/dist/index.d.ts:11
error Command failed with exit code 2.
Getting these errors when trying to build via typescript.
Steps to reproduce
Try to build a project with gitbeaker
Expected behaviour
The code should build via TS
Actual behaviour
The code is not building with the errors above
Possible fixes
none
Checklist
- I have checked that this is not a duplicate issue.
- I have read the documentation.
Thats odd. Ill give it a look and follow up!
What does your tsconfig look like?
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"lib": [
"es2020", "esnext"
],
"target": "es2020",
"sourceMap": true,
"outDir": "./dist",
"allowJs": true,
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"allowSyntheticDefaultImports": true,
"incremental": true,
"resolveJsonModule": true,
"strict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"experimentalDecorators": true,
"baseUrl": "./"
},
"exclude": [
"node_modules",
"dist",
"**/*.test.ts"
],
"include": ["./**/*.js","./**/*.ts"]
}
Hmm, tis odd, ReadableStream type has been available for a while: https://nodejs.org/docs/latest-v18.x/api/webstreams.html#class-readablestream
Do you include "@types/node"?
Than you very much for the fast help, unfortunately adding the node types (using version "@types/node": "20.10.5",
) did not help, I am still encountering the same error. Also shouldn't this be included in your package dependencies if your code relies on this package?
Its a dev dependency for typescript nodejs built in types, it isnt needed for the package itself. Any chance you could put together a sample project for me to investigate further with?
Its a dev dependency for typescript nodejs built in types, it isnt needed for the package itself. Any chance you could put together a sample project for me to investigate further with?
https://github.com/akirilyuk/gitbeaker-ts-error-example Getting the exactly same error with this example project. Btw we could argue about not exporting the node built in types package. In my opinion since you are using them in your exported types, it should also be exported, since I for example do not always have the @types/node package when working with node and typescript. And since your exported code relies on these types, it could rather go into dependencies for developer convenience.
Here is the issue. In your tsconfig file:
{
....
"lib": [
"es2020", "esnext"
],
..
}
By explicitly excluding the default "dom" library, you are gonna miss key types like FormData, Blob, even console.
Just modify this to:
{
....
"lib": [
"es2020", "esnext", "dom"
],
..
}
*you dont need to include @types/node. It was just an idea for debugging.
THX!