安装
添加为 devDependencies 内 package.json数字 :
npm i -D @aws-lite/dynamodb-types
确定你还有 @aws-lite/dynamodb 已安装.
使用和配置
Javascript VSCode 智能化
在Javascript项目中,环境类型会自动被加载.
import awsLite from '@aws-lite/client';
const client = await awsLite({ region: 'us-east-1' });
const { Item: myArticle } = await client.dynamodb.GetItem({
TableName: 'articles',
Key: { articleID: '123-ABC' },
});
client.dynamodb.GetItem 编辑 myArticle 结果是有Intellisense.
类型脚本 tsconfig
将此软件包添加到 compilerOptions.types
示例
{
"extends": "@tsconfig/node-lts/tsconfig.json",
"compilerOptions": {
"types": [
"@aws-lite/dynamodb-types"
]
}
}
使用参考类型
个人档案或 index.d.ts 文档.
/// <reference types="@aws-lite/dynamodb-types" />
亚姆v
/// <reference path="./node_modules/@aws-lite/dynamodb-types/index.d.ts" />