aliyun / aliyun/credentials-nodejs
为什么我的ts类型不对呢
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 15
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Description
// 依赖的模块可通过下载工程中的模块依赖文件或右上角的获取 SDK 依赖信息查看
import Dysmsapi20170525, * as $Dysmsapi20170525 from '@alicloud/dysmsapi20170525';
import * as $OpenApi from '@alicloud/openapi-client';
import * as $Util from '@alicloud/tea-util';
import Credential from '@alicloud/credentials';
export default class AliyunClient {
/**
- @remarks
- 使用凭据初始化账号Client
- @returns Client
- @throws Exception
*/
static createClient(): Dysmsapi20170525 {
// 工程代码建议使用更安全的无AK方式,凭据配置方式请参见:https://help.aliyun.com/document_detail/378664.html。
let credential = new Credential({
})
let config = new $OpenApi.Config({
credential: credential,
});
// Endpoint 请参考 https://api.aliyun.com/product/Dysmsapi
config.endpoint = `dysmsapi.aliyuncs.com`;
return new Dysmsapi20170525(config);
}
static async main(): Promise {
let client = this.createClient();
let sendSmsRequest = new $Dysmsapi20170525.SendSmsRequest({
phoneNumbers: "17368xxxxxx",
signName: "镇江市简界科技",
templateCode: "SMS_5xxxxxx",
templateParam: "{"name":"1234"}",
});
let runtime = new $Util.RuntimeOptions({ });
try {
let resp = await client.sendSmsWithOptions(sendSmsRequest, runtime);
console.log(JSON.stringify(resp, null, 2));
} catch (error:any) {
// 此处仅做打印展示,请谨慎对待异常处理,在工程项目中切勿直接忽略异常。
// 错误 message
console.log(error.message);
// 诊断地址
console.log(error.data["Recommend"]);
}
}
}
Credential
此表达式不可构造。
类型 "typeof import("/Users/nijie/Documents/\u6700\u65B0\u6784\u5EFA/gamerApp_server/node_modules/@alicloud/credentials/dist/src/client")" 没有构造签名。ts(2351)
Dysmsapi20170525
不能将命名空间“Dysmsapi20170525”用作类型
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two TypeScript diagnostics in the shown imports and calls, especially @alicloud/credentials and @alicloud/dysmsapi20170525. Inspect the published declarations under node_modules/@alicloud/credentials/dist/src/client and the SDK package typings, then verify that the intended credential construction and Dysmsapi20170525 type usage are accepted by TypeScript.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, typescript
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100