Skip to content

Commit

Permalink
Update package.json - add types to exports
Browse files Browse the repository at this point in the history
when changing moduleResolution from node to bundler (as in https://github.com/vercel/next.js/pull/51957/files#diff-066cacecd32e0ca72d47360ddb35c19a676835816eed05163e05564ec0874590)in tsconfig.json following errors occurs:

./pages/sitemap.xml/index.tsx:2:36
Type error: Could not find a declaration file for module 'next-sitemap'. 'C:/dev/frontend/project/node_modules/next-sitemap/dist/esm/index.js' implicitly has an 'any' type.
  There are types at 'C:/dev/frontend/project/node_modules/next-sitemap/dist/@types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'next-sitemap' library may need to update its package.json or typings.

  1 | import type { GetServerSideProps } from "next";
> 2 | import type { ISitemapField } from "next-sitemap";

The error can be fixed via copying the types to the exports "." section in package.json (as described here: https://stackoverflow.com/a/76212193/1548552)
  • Loading branch information
Barokai committed Jul 26, 2023
1 parent a0c5c52 commit 499e6cb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/next-sitemap/package.json
Expand Up @@ -8,7 +8,8 @@
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
"require": "./dist/cjs/index.js",
"types": "./dist/@types/index.d.ts"
}
},
"files": [
Expand Down

0 comments on commit 499e6cb

Please sign in to comment.