簡體   English   中英

如何為現有的 npm 插件模塊定義類型?

[英]how to define a type for an existing npm plugin module?

我嘗試將使用nodemailernodemailer-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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM