小编Dan*_*rns的帖子

如何使用定义文件创建 npm 包?

如何使用定义文件创建 NPM 包,其中仅在*.ts文件中声明接口。

假设我们有两个接口和一个类定义:

export interface A {
 id: number;
}

export interface B {
 name: string;
}

export class C {
}
Run Code Online (Sandbox Code Playgroud)

我需要将这些*.ts文件打包到 npm 包中,该怎么做?我应该将它们导出index.ts吗?

我的package.json是:

{
  "name": "npm",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}
Run Code Online (Sandbox Code Playgroud)

我的tsconfig.json是:

"compilerOptions": {
   "target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', …
Run Code Online (Sandbox Code Playgroud)

javascript node.js npm typescript

7
推荐指数
1
解决办法
208
查看次数

如何计算 Deno 中函数执行所需的时间

我需要获得以毫秒为单位的执行时间。使用 Deno 我们可以做什么?

deno

3
推荐指数
1
解决办法
1403
查看次数

JavaScript string interpolation on strings assigned as property values in objects

I have the following object:

var obj = {
   number: "123456789"
   tel: `The clients phone number is ${number}. Please call him!`
Run Code Online (Sandbox Code Playgroud)

How can I insert the number value in the tel-string?

javascript string-interpolation

2
推荐指数
1
解决办法
42
查看次数