-
Notifications
You must be signed in to change notification settings - Fork 615
Typescript types for required and optional attributes are not generated correctly #5992
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
Comments
Hi @rehos , Thanks for reaching out. The reason why we generate " | undefined" for our types, is intentionally designed for forward compatibility reasons. This allows AWS services to change their APIs by making previously To improve the typescript experience, you can cast your client to be an Thanks, |
@RanVaknin, thank you for the clarification for |
TS playground demonstrating the secondary issue: TSP |
I understand the forward compatibility reasoning behind allowing For example, in
Problems: Possible solution:
Temporary workaround:
|
All fields contain |
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. |
Uh oh!
There was an error while loading. Please reload this page.
Checkboxes for prior research
Describe the bug
Typescript types are for required and optional attributes are not generated corrrectly. I.e. required attributes can accept undefined. And optional attributes cannot accept
undefined
when setting the typescript compilation optionexactOptionalPropertyTypes
totrue
.Fixing this will probably also fix this issue
SDK version number
3.540.0
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v20.11.0
Reproduction Steps
Just look at the generated typescript types for all clients
Observed Behavior
Typescript types of required attributes are all generated as a union with their type and
undefined
. And optional attributes are not generated as a union with undefined which gives problems when setting the typescript compilation optionexactOptionalPropertyTypes
totrue
.See for example the in the DynamoDB client the TableName and IndexName attributes in the type QueryInput:
Expected Behavior
I expect required attributes cannot be set to
undefined
while optional attributes can acceptundefined
. Also when setting the typescript compilation optionexactOptionalPropertyTypes
totrue
.So I expected that the generated code for the example above is generated as:
Possible Solution
Probably the following line in DocumentClientCommandGenerator.java:
should be changed to:
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: