我正在用typescript创建nodemodules,但是我不知道如何键入从nodejs js文件中的typescript中传递的检查输入数据。如果没有办法,用typescript而不是js创建节点模块有什么好处
添加一些代码以更好地理解
In my package index.ts
export class SampleSDK{
name:String ;
constructor(name:String){
this.name = name;
}
getName(){
return this.name;
}
}
in index.js
var express = require('express');
var router = express.Router();
var SampleSdk = require("sample-sdk");
/* GET home page. */
router.get('/', function(req, res, next) {
let fdConnectSDK = new SampleSdk.SampleSDK(1000);
console.log(fdConnectSDK.getName()); // this is printing 1000 instead i expect it should throw error
res.send("HELLO")
});
module.exports = router;