Technical questionAccepted answer
AWS Javascript SDK v3 - Typescript doesn't compile due to error TS2304: Cannot find name 'ReadableStream'
Kerruba
Feb 19
0 views1
I'm trying to build my project that uses the AWS Javascript SDK v3. Here my tsconfig.json
{
"compilerOptions": {
"target":"ES2020",
"module": "commonjs",
"lib": ["es2020"],
"outDir": "dist",
"resolveJsonModule": true,
},
"exclude": [
"coverage",
"node_modules",
"dist",
"tests"
]
}
And here an example of the build error I get (I've strip out some of the output for brevity sake):
node_modules/@aws-sdk/client-s3/types/models/models_1.d.ts:727:23 - error TS2304: Cannot find name 'ReadableStream'.
node_modules/@aws-sdk/client-s3/types/models/models_1.d.ts:727:40 - error TS2304: Cannot find name 'Blob'.
node_modules/@aws-sdk/util-dynamodb/types/models.d.ts:19:86 - error TS2304: Cannot find name 'File'.
I don't understand why this is giving me such an issue, even if I have installed the @types/node module to support node typing
1 answer
Accepted answer · original discussion
Kerruba
PermalinkFeb 19
Turned out that in order for typescript to find the Blob, File etc. names I had to add the dom entry to the lib in my tsconfig.json. Here my final tsconfig, which allow me to build the project correctly
{
"compilerOptions": {
"target":"ES2020",
"module": "commonjs",
"lib": ["es2020", "dom"],
"outDir": "dist",
"resolveJsonModule": true,
},
"exclude": [
"coverage",
"node_modules",
"dist",
"tests"
]
}
0 question comments
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.