From fd8aabd3768c199abc717dc6d793ef136419be72 Mon Sep 17 00:00:00 2001 From: Morgan Roderick Date: Wed, 11 Nov 2020 12:07:10 +0100 Subject: [PATCH] Generate .d.ts from JSDoc See https://humanwhocodes.com/snippets/2020/10/create-typescript-declarations-from-javascript-jsdoc/ --- .nvmrc | 1 + package-lock.json | 6 ++++++ package.json | 7 +++++-- tsconfig.json | 10 ++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 .nvmrc create mode 100644 tsconfig.json diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..55d1782 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v14.15.0 diff --git a/package-lock.json b/package-lock.json index 073e3b7..b2211e3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9180,6 +9180,12 @@ "is-typedarray": "^1.0.0" } }, + "typescript": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.0.5.tgz", + "integrity": "sha512-ywmr/VrTVCmNTJ6iV2LwIrfG1P+lv6luD8sUJs+2eI9NLGigaN+nUQc13iHqisq7bra9lnmUSYqbJvegraBOPQ==", + "dev": true + }, "uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", diff --git a/package.json b/package.json index 626c9b4..b333e3a 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "author": "Christian Johansen", "license": "BSD-3-Clause", "main": "./lib/samsam", + "types": "./dist/samsam.d.ts", "repository": { "type": "git", "url": "https://github.com/sinonjs/samsam.git" @@ -15,9 +16,10 @@ }, "scripts": { "benchmark": "node lib/deep-equal-benchmark.js", - "build": "run-s build:dist-folder build:bundle", + "build": "run-s build:dist-folder build:bundle build:type-defs", "build:bundle": "rollup -c", "build:dist-folder": "mkdirp dist", + "build:type-defs": "tsc", "jsdoc": "jsdoc -c jsdoc.conf.json", "lint": "eslint .", "prepublishOnly": "npm run build && mkdocs gh-deploy -r upstream || mkdocs gh-deploy -r origin", @@ -74,7 +76,8 @@ "proxyquire-universal": "^2.1.0", "proxyquireify": "^3.2.1", "rollup": "^1.23.0", - "rollup-plugin-commonjs": "^10.1.0" + "rollup-plugin-commonjs": "^10.1.0", + "typescript": "^4.0.5" }, "nyc": { "exclude": [ diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..3bdd0d0 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,10 @@ +{ + "include": [ + "dist/*.js" + ], + "compilerOptions": { + "declaration": true, + "emitDeclarationOnly": true, + "allowJs": true + } +}