相关疑难解决方法(0)

创建一个 TypeScript 库并在 Node.js 中使用 ES6 和 TypeScript

我想创建一个 TypeScript 库作为可以在 Node.js 中使用的私有 npm 包(包括6.x)使用 ES6@types支持和 TypeScript。

该库的目标是扩展Request类型express并提供额外的属性。

我创建了一个新的 Node.js 项目并添加了这个tsconfig.json

{
  "compilerOptions": {
    "target": "es2015",
    "module": "commonjs",
    "sourceMap": true,
    "declaration": true,
    "outDir": "./dist",
    "strict": true,
    "types": ["mocha"]
  }
}
Run Code Online (Sandbox Code Playgroud)

这些是 的相关部分package.json

{
  "name": "@myscope/my-lib",
  "main": "dist",
  "scripts": {
    "build": "rm -rf ./dist && ./node_modules/.bin/tsc",
    "test": "./node_modules/.bin/mocha test"
  },
  "private": true,
  "dependencies": {
    "joi": "11.4.0"
  },
  "devDependencies":  {
    "mocha": "^5.2.0",
    "express": "^4.16.4",
    "@types/express": "^4.16.1",
    "@types/joi": "^14.3.0", …
Run Code Online (Sandbox Code Playgroud)

node.js jsdoc typescript

0
推荐指数
1
解决办法
3811
查看次数

标签 统计

jsdoc ×1

node.js ×1

typescript ×1