-
Notifications
You must be signed in to change notification settings - Fork 578
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
Dom lib required for TS to compile in Node app #2896
Comments
Getting typescript isomorphic code to compile without assertions across environments generally sucks, but in the public interface looks something like: // Declare interfaces that will get merged with the real definitions in lib.dom and @types/node
declare global {
export interface ReadableStream {}
export namespace NodeJS {
export interface Readable {}
}
// ...
}
export type InputStream = ReadableStream | NodeJS.Stream; Really, it's missing a typescript feature, maybe |
I hit this error with $ yarn build
yarn run v1.22.10
$ tsc
lambda-fns/node_modules/@aws-sdk/util-dynamodb/dist-types/ts3.4/models.d.ts:12:59 - error TS2304: Cannot find name 'Blob'.
12 export declare type NativeAttributeBinary = ArrayBuffer | Blob | Buffer | DataView | File | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
~~~~
lambda-fns/node_modules/@aws-sdk/util-dynamodb/dist-types/ts3.4/models.d.ts:12:86 - error TS2304: Cannot find name 'File'.
12 export declare type NativeAttributeBinary = ArrayBuffer | Blob | Buffer | DataView | File | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
~~~~
Found 2 errors.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. |
For discussions of how this might be fixed, see https://stackoverflow.com/questions/65848540 and microsoft/TypeScript#31894. |
Sadly I think the most common solution you'll find in the wild is people adding a triple-slash reference to DOM types, which, yes, pollutes the global namespace of anyone who includes your library with all the DOM types. You might also be interested in following microsoft/TypeScript-DOM-lib-generator#1207 which, if implemented, could allow you to import individual types from the DOM without having them exist in global scope. |
- Remove CORS related code - Minor refactoring - Updating comments Removing 'dom' from tsconfig.json produces error during tsc build during github action Run Tests. - required to workaround aws/aws-sdk-js-v3#2896 Ticket: AT-7050
- Remove CORS related code - Minor refactoring - Updating comments Removing 'dom' from tsconfig.json produces error during tsc build during github action Run Tests. - required to workaround aws/aws-sdk-js-v3#2896 Ticket: AT-7050
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Describe the bug
Dom lib required by typescript in order to successfully compile node app
Your environment
SDK version number
@aws-sdk/lib-dynamodb@3.36.0
Is the issue in the browser/Node.js/ReactNative?
Node.js
Details of the Node.js
v12.22.4
Steps to reproduce
import { DynamoDBDocumentClient } from "@aws-sdk/lib-dynamodb";
into hello world filetsc
to compile projectObserved behavior
The source code fails to compile with error:
Expected behavior
lib installed into node app should not require "dom" types to compile
Additional context
If you add "dom" to lib array in tsconfig.json, source code will compile successfully
The text was updated successfully, but these errors were encountered: