[英]how to define a type for an existing npm plugin module?
我嘗試將使用nodemailer和nodemailer-html-to-text插件的代碼庫轉換為打字稿。
Nodemailer 有@types定義,但nodemailer-html-to-text
沒有。
如何為這個模塊創建我自己的類型定義?
我試圖在我的項目中創建一個@types/nodemailer-html-to-text.d.ts
文件:
declare module 'nodemailer-html-to-text' {
}
從這里,我想這個文件導出htmlToText
類型的函數定義Mail.PluginFunction ,但我不知道該怎么辦呢?
在這里找到了module-plugin.d.ts :
declare module 'nodemailer-html-to-text' {
import * as Mail from 'nodemailer/lib/mailer'
export function htmlToText(): Mail.PluginFunction
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.