英文:
converting types from aws sdk v2 to v3 (typescript)
问题
我正在将一个 TypeScript 代码库从 AWS SDK 版本 2 迁移到版本 3。在我的代码中,我已经使用了 AWS SDK 版本 2 中的一些类型,如下所示:
import * as AWS from 'aws-sdk';
export async function uploadFn(
s3: AWS.S3,
........
)
然而,对于诸如 AWS.S3
(以及其他类型)的类型,在版本 3 中我无法找到应该使用的等效类型,而且我只能找到在 AWS SDK 版本 2 中通常会使用 S3 对象调用的函数的客户端/命令等效类型。是否有人知道在版本 3 中是否存在类似 AWS.S3
(如上所示的代码)的等效类型,或者我应该更改为类型 any
?
英文:
I am migrating a typescript codebase from aws sdk v2 to v3. In my code I have used several types from aws sdk v2 as follows:
import * as AWS from 'aws-sdk';
export async function uploadFn(
s3: AWS.S3,
........
)
However, for types such as AWS.S3
(and others) I can't find the equivalent type I should use in v3, and I've only been able to find the client/command equivalents of the functions I would normally call with an S3 object in aws sdk v2. Does anyone know if an equivalent type of AWS.S3
(as in the code above) exists in v3, or should I change to type any
?
答案1
得分: 3
v2的AWS
对象没有v3的等效物。v3 SDK是模块化的:
现在SDK已分割成多个包。SDK的2.x版本包含对每个服务的支持。
例如,S3客户端和命令打包在@aws-sdk/client-s3中:
import { S3Client, ListBucketsCommand } from '@aws-sdk/client-s3';
v3包具有一流的TypeScript支持。
英文:
There is no v3 equivalent of the v2 AWS
object. The v3 SDK is modular:
> The SDK is now split up across multiple packages. The 2.x version of the SDK contained support for every service.
The S3 client and commands, for instance, are packaged in @aws-sdk/client-s3:
import { S3Client, ListBucketsCommand } from '@aws-sdk/client-s3';
The v3 packages have first-class Typescript support.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论