diff --git a/.gitignore b/.gitignore index 26ab9964..698046b1 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ npm-debug.log package-lock.json .nyc_output dist +/types/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 69ec0e89..14acbcc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # @digitalbazaar/vc ChangeLog +### Added +- Generate TypeScript declarations for published packages. + ## 7.1.0 - 2024-10-10 ### Added diff --git a/package.json b/package.json index a8391f89..b0622ed9 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,12 @@ }, "license": "BSD-3-Clause", "type": "module", - "exports": "./lib/index.js", + "main": "./lib/index.js", + "types": "./types/index.d.ts", "files": [ - "lib/**/*.js" + "lib/**/*.js", + "types/**/*.d.ts", + "types/**/*.d.ts.map" ], "dependencies": { "@digitalbazaar/credentials-context": "^3.1.0", @@ -45,6 +48,7 @@ "@digitalbazaar/ed25519-verification-key-2018": "^4.0.0", "@digitalbazaar/multikey-context": "^2.0.1", "@digitalbazaar/odrl-context": "^1.0.0", + "@types/node": "^22.3.0", "c8": "^10.1.2", "chai": "^4.5.0", "cross-env": "^7.0.3", @@ -64,6 +68,8 @@ "klona": "^2.0.6", "mocha": "^10.7.0", "mocha-lcov-reporter": "^1.3.0", + "rimraf": "^6.0.1", + "typescript": "^5.5.4", "uuid": "^10.0.0", "veres-one-context": "^12.0.0", "webpack": "^5.93.0" @@ -94,6 +100,8 @@ "lint": "eslint 'lib/**/*.js' 'test/**/*.js'", "coverage": "cross-env NODE_ENV=test c8 npm run test-node", "coverage-ci": "cross-env NODE_ENV=test c8 --reporter=lcovonly --reporter=text-summary --reporter=text npm run test-node", - "coverage-report": "c8 report" + "coverage-report": "c8 report", + "prepack": "npm run build-types", + "build-types": "rimraf types & tsc -p tsconfig.types.json" } -} +} \ No newline at end of file diff --git a/tsconfig.types.json b/tsconfig.types.json new file mode 100644 index 00000000..4354fd60 --- /dev/null +++ b/tsconfig.types.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "allowJs": true, + "declaration": true, + "emitDeclarationOnly": true, + "outDir": "types", + "declarationMap": true + }, + "include": [ + "lib/**/*.js" + ] +} \ No newline at end of file