我得到了这段代码:
import nodemailer from "nodemailer";
const transporter = nodemailer.createTransport({
host: "smtp...",
port: 587,
secure: false,
requireTLS: true,
auth: {...}
});
const result = await transporter.sendMail({
from: "XXX",
to: "YYY",
subject: "ZZZ",
text: "WWW"
});Typescript目前正在将result评估为any。

这是正确的吗?
我还安装了@types/nodemailer。这是其中包含的类型定义:

即使我尝试直接将其键入为SentMessageInfo,也会得到any
import { SentMessageInfo } from "nodemailer";
const result: SentMessageInfo = await transporter.sendMail({...});

我做错了什么吗?或者真的没有类型定义?
transporter的类型似乎是正确的(类型为Mail)。

发布于 2020-12-17 01:38:30
类型正确,SentMessageInfo is simply an alias for any
export type SentMessageInfo = any;https://stackoverflow.com/questions/65328168
复制相似问题