From 628d0587a71450bcf713b3852ff2550d26d436bf Mon Sep 17 00:00:00 2001 From: Val Date: Sat, 24 Feb 2024 15:26:30 -0800 Subject: [PATCH] Put type declarations next to JS file (fixes #84) It seems that setting `"types": "index.d.ts"` in `package.json` doesn't cut it in all cases, and some build toolchains really want the `.d.ts` files to be next to the `.js` file it's associated with. So even if since 3.0.0 the `.d.ts` file is the same for `esm/index.js` and `cjs/index.js`, we still need to copy an identical declaration file next to the JS files. --- .gitignore | 3 ++- CHANGELOG.md | 10 +++++++++- package.json | 6 ++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 7a3e8fe..92c3ac4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /node_modules /esm/index.js +/esm/index.d.ts /cjs/index.js -/index.d.ts +/cjs/index.d.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index f3a2c21..9b19216 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [3.0.1] - 2024-02-24 +* Fix an issue with type declarations resolution. ([#84]) + ## [3.0.0] - 2024-02-21 * Export `FetchCookieImpl` interface. ([#81]) * **Breaking:** move away from CJS `module.exports = fetchCookie` style, @@ -121,7 +124,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [0.1.0] - 2015-04-04 * Initial release. -[Unreleased]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.1.0...HEAD +[Unreleased]: https://github.com/valeriangalliat/fetch-cookie/compare/v3.0.1...HEAD +[3.0.1]: https://github.com/valeriangalliat/fetch-cookie/compare/v3.0.0...v3.0.1 +[3.0.0]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.2.0...v3.0.0 +[2.2.0]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.1.0...v2.2.0 [2.1.0]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.0.5...v2.1.0 [2.0.5]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.0.4...v2.0.5 [2.0.4]: https://github.com/valeriangalliat/fetch-cookie/compare/v2.0.3...v2.0.4 @@ -184,3 +190,5 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. [#70]: https://github.com/valeriangalliat/fetch-cookie/issues/70 [#71]: https://github.com/valeriangalliat/fetch-cookie/issues/71 [#72]: https://github.com/valeriangalliat/fetch-cookie/issues/72 +[#81]: https://github.com/valeriangalliat/fetch-cookie/pull/81 +[#84]: https://github.com/valeriangalliat/fetch-cookie/issues/84 diff --git a/package.json b/package.json index 23b86a5..b0ac6bb 100644 --- a/package.json +++ b/package.json @@ -11,14 +11,16 @@ "./package.json": "./package.json", ".": { "import": { + "types": "./esm/index.d.ts", "default": "./esm/index.js" }, "require": { + "types": "./cjs/index.d.ts", "default": "./cjs/index.js" } } }, - "types": "index.d.ts", + "types": "cjs/index.d.ts", "repository": "valeriangalliat/fetch-cookie", "scripts": { "build": "esbuild src/*.ts --format=esm --outdir=esm && esbuild src/*.ts --format=cjs --outdir=cjs", @@ -29,7 +31,7 @@ "test": "npm run build && mocha", "test-import": "node test/cjs/import.js && ts-node test/cjs/import.ts", "type-check": "tsc -noEmit", - "type-declarations": "tsc --project tsconfig.build.json --declaration --emitDeclarationOnly --outDir ." + "type-declarations": "tsc --project tsconfig.build.json --declaration --emitDeclarationOnly --outDir esm && cp esm/index.d.ts cjs" }, "dependencies": { "set-cookie-parser": "^2.4.8",