Quantcast
Channel: CNode:Node.js专业中文社区
Viewing all articles
Browse latest Browse all 14821

typescript的声明文件.d.ts,是否可以在 nodejs 中使用了呢?

$
0
0

我的目的是使用 typescript的声明文件.d.ts,结合模块包的js代码,使在引用编写阶段有足够的提示和报警,目前使用如下的代码,并没有起到效果,请大佬指点下,或者是否有其他方法 node-version:v10.16.0

// module/index.d.ts
export function add(a: number, b: number): number;
// module/index.js
function add(a, b) {
  return a + b;
}

module.exports = add;

// index.js
const add = require('./module');

const sumAb = add("2", 2);

console.log(sumAb);

Viewing all articles
Browse latest Browse all 14821

Trending Articles