Skip to content
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

References to V2 AWS SDK and an unknown DynamoDBClientV3 #265

Closed
guentherwieser opened this issue Jul 13, 2022 · 4 comments
Closed

References to V2 AWS SDK and an unknown DynamoDBClientV3 #265

guentherwieser opened this issue Jul 13, 2022 · 4 comments

Comments

@guentherwieser
Copy link

Have been trying to get 1.15.0-beta.10 running with AWS SDK V3, but I always get the following errors:

`node_modules/@typedorm/document-client/cjs/src/types/document-client-types.d.ts:1:8 - error TS1192: Module '"/Users/xxx/git/yyyy/node_modules/aws-sdk/index"' has no default export.

1 import AWS, { DynamoDB } from 'aws-sdk';
~~~

node_modules/@typedorm/document-client/cjs/src/types/document-client-types.d.ts:2:8 - error TS1192: Module '"/Users/xxx/git/yyyy/node_modules/@aws-sdk/client-dynamodb/dist-types/ts3.4/index"' has no default export.

2 import DynamoDBClientV3 from '@aws-sdk/client-dynamodb';
`

DynamoDBClientV3 is something I cannot find in any related code or via Google. And the import of the aws-sdk package looks also weird as this V2 package is not documented to be needed when working with typedorm and AWS SDK V3.

Any idea what goes wrong here? Is this something that can be reproduced, or is it related to my setup (e.g. tsconfig.json misses something important)?

@whimzyLive
Copy link
Member

@NoComment73
This looks like an issue with your tsconfig -
can you see if you have "allowSyntheticDefaultImports": true, enabled in compilerOptions of the project tsconfig.

The changes to newer SDK v2 and v3 are briefly documented here or more in detail here.

You can also refer to the official examples of using TypeDORM with SDK versions 2 and 3 here.

P.S. If the typing mentioned above is still an issue with you, please try to reproduce the issue in public repository with minimum config and share the link.

@guentherwieser
Copy link
Author

Setting "allowSyntheticDefaultImports" to true solved the problem, thx!

Don't know if this is related, but I dare to ask here: when I deploy my code as an AWS Lambda, I get the following error:

{
"errorType": "MissingReflectMetadata",
"errorMessage": "Could not reflect metadata of type design:type, did you forget to enable "emitDecoratorMetadata" on compiler options?",
"trace": [
"MissingReflectMetadata: Could not reflect metadata of type design:type, did you forget to enable "emitDecoratorMetadata" on compiler options?",
" at /var/task/index.js:35433:13",
" at __decorateClass (/var/task/index.js:24:24)",
" at Object. (/var/task/index.js:35695:1)",
" at Module._compile (internal/modules/cjs/loader.js:1085:14)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)",
" at Module.load (internal/modules/cjs/loader.js:950:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:790:12)",
" at Module.require (internal/modules/cjs/loader.js:974:19)",
" at require (internal/modules/cjs/helpers.js:101:18)",
" at _tryRequireFile (/var/runtime/UserFunction.js:71:32)"
]
}

I've added "import 'reflect-metadata'" into the entry point of the Lambda, have set "emitDecoratorMetadata": true in tsconfig. Any ideas?

@whimzyLive
Copy link
Member

whimzyLive commented Jul 20, 2022

Hi @NoComment73

Which build tool are you using? Is that esbuild by any chance?
If you are using esbuild to transpile your typescript into javascript then this will not work mainly because esbuild has opted to not support for transpiling experimentalDecorator feature of typescript.

@guentherwieser
Copy link
Author

Yep, esbuild, in the meanwhile, I'm aware of the experimentalDecorator issues with it ;-) Thx for the update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants