javascript - 如何实现像 Babel 这样的插件注册?
问题描述
如何实现像 Babel 这样的插件注册?打字稿支持吗?如果不是,为什么?
class PluginA {
constructor(platform: Platform, options: { a: string }) { }
print() { }
}
class PluginB {
constructor(platform: Platform, options: { b: number }) { }
print() { }
}
const p = new Platform({
pluginSettings: [
[PluginA, { a: 123 }], // Expect an error but no
[PluginB, { b: 'abc' }], // Expect an error but no
],
})
我希望[PluginA, { a: 123 }]
has type of[typeof PluginA, { a: string }]
和[PluginB, { a: 'abc' }]
has type of [typeof PluginB, { a: number }]
,但事实并非如此。
解决方案
推荐阅读
- java - 适用于 Android 的 Firebase 数据库,以字符串形式返回地图数据
- php - OKEX提现错误10006
- regex - JS6 使用第一个数字作为其他变量的值编写 regExp
- sql - 不能在 UPDATE 中使用聚合函数
- javascript - 获取元素,javascript,html
- ios - 如何在 iOS Swift 中录制视频时拍摄照片?
- javascript - ajax 中的模态按钮事件
- python - 如果列数不同,如何处理从源 spark df 到 hive 表的插入
- html - 工具提示悬停的过渡在 IE 上不起作用,在 Google Chrome 中运行良好
- jquery - 使用 jQuery 将一个元素文本与隐藏元素文本进行比较