MailData 目前能够采用dynamic_template_data
属性,但它的接口缺少该字段。
以类似的方式, PersonalizationData 有一个名为dynamicTemplateData
的字段,据我所知,它对动态模板没有任何作用。 但是,如果我们使用dynamic_template_data
,模板的把手将被正确替换(但它会引发相同的 tslint 错误)。
它可能与此提交有关,其中dynamicTemplateData
应该改为dynamic_template_data
https://github.com/sendgrid/sendgrid-nodejs/pull/716/files
dynamic_template_data
的字段声明类型为 MailData 的变量const mailOptions: MailData = {
...
dynamic_template_data: {
hello: "world
}
}
预期行为:
tslint 没有显示错误
实际行为
tslint 引发Object literal may only specify known properties
错误
"@sendgrid/helpers": "^6.3.0",
"@sendgrid/mail": "^6.3.1",
Node.js Version: v10.15.3
MailData 上仍然不存在 dynamic_template_data:
/** <strong i="6">@type</strong> {import('@sendgrid/helpers/classes/mail').MailData} */
const emailContent = {
to: toEmail,
from: this.SG_USER,
templateId,
asm: {
groupId,
},
dynamic_template_data: {
...body,
testingHead: debug.head,
testingBody: debug.body,
},
mail_settings: {
sandbox_mode: {
enable: sendgridSandboxMode,
},
},
};
Type '{ to: string; from: any; templateId: string; asm: { groupId: number; }; dynamic_template_data: any; mail_settings: { sandbox_mode: { enable: any; }; }; }' is not assignable to type 'MailData'.
Object literal may only specify known properties, but 'dynamic_template_data' does not exist in type 'MailData'. Did you mean to write 'dynamicTemplateData'?ts(2322)
我也看到了这个问题。 @okhomenko你能找到解决办法吗?
2021年同样的问题仍在发生
最有用的评论
我也看到了这个问题。 @okhomenko你能找到解决办法吗?