Description
Describe the feature
TypeScript 4.4 added support for a setting in tsconfig.json: exactOptionalPropertyTypes
. See the announcement here:
https://devblogs.microsoft.com/typescript/announcing-typescript-4-4/#exact-optional-property-types
With this flag enabled, undefined
is no longer assignable to optional members unless they explicitly have undefined
in their signature.
The AWS SDK gracefully handles the case where a parameter is specified but undefined
. Specifically, the overwhelming majority of the SDK transmits requests with JSON.stringify
which will omit undefined
values from the payload entirely. Therefore, the AWS SDK should add undefined
to most of the generated d.ts input types.
Use Case
exactOptionalPropertyTypes
brings the types of a project closer to the actual shape during runtime. It should be used in all new projects when possible. Currently, using the AWS SDK with this option enabled is unreasonably cumbersome.
Proposed Solution
I believe this can be implemented with minor changes to the code generation. Instead of outputting ?:
you will output ?: undefined |
.
Other Information
This is the PR of the feature from TypeScript microsoft/TypeScript#43947
Acknowledgements
- I may be able to implement this feature request
- This feature might incur a breaking change
SDK version used
v3.184.0
Environment details (OS name and version, etc.)
N/A