Importing types
Useimport type for type-only imports to keep your runtime bundle clean:
Minimum TypeScript version
The SDK does not have an official minimum supported TypeScript version. We recommend using a recent version. You can check the TypeScript version used in SDK development in the rootpackage.json of the repository.
Why fields are | undefined
Request and response structure fields are typed as unions with | undefined:
| undefined from inputs and outputs, @smithy/types provides a type transform for this:
@smithy/types documentation for full usage.
Why streaming outputs are union types
Streaming response fields (likeGetObjectOutput.Body) have a union type:
requestHandler implementation varies by platform (node:https-based for Node.js, fetch-based for browsers) and service. The exact streaming type is not known at compile time.
Narrowing the streaming type
If you want to narrow the streaming payload type (for example, to always be a Node.jsReadable), @smithy/types provides a type transform for this:
@smithy/types documentation for full usage instructions.
Bare-bones vs aggregated clients
The SDK exposes two client styles. Both are fully typed.Typing async credential providers
Thecredentials configuration field accepts either a static credentials object or an async function:
expiration field, the SDK will call the provider again before the credentials expire.