Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update exports for types #134

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

PaoloRollo
Copy link

Importing @ensdomains/thorin returns the following error:

Could not find a declaration file for module '@ensdomains/thorin'. 'PROJECT_DIR/node_modules/@ensdomains/thorin/dist/index.es.js' implicitly has an 'any' type.
There are types at 'PROJECT_DIR/node_modules/@ensdomains/thorin/dist/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@ensdomains/thorin' library may need to update its package.json or typings.

It seems it's unable to resolve the types defined in the package.json file. A possibile solution is the proposed one, where the types are set explicitly in the exports.".".import.types field:

"import": {
    "types": "./dist/types/index.d.ts",
    "default": "./dist/index.es.js"
}

For reference the tsconfig.json file used is the default one from Next.js:

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "bundler",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/*": ["./*"]
    },
    "forceConsistentCasingInFileNames": true
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}

@PaoloRollo
Copy link
Author

It seems to be connected to the moduleResolution property in the tsconfig.json file. Using node instead of the default bundler the package works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant