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

Could not find a declaration file for module '@stoplight/json-schema-viewer' with moduleResolution "Bundler" #267

Open
au5ton opened this issue Oct 4, 2024 · 0 comments

Comments

@au5ton
Copy link

au5ton commented Oct 4, 2024

Context

I can't use the library.

Current Behavior

Using "moduleResolution": "Bundler", in my tsconfig.json, I get the following error:

import {} from '@stoplight/json-schema-viewer'
Could not find a declaration file for module '@stoplight/json-schema-viewer'. 'c:/.../project/node_modules/@stoplight/json-schema-viewer/index.mjs' implicitly has an 'any' type.
  There are types at 'c:/.../project/node_modules/@stoplight/json-schema-viewer/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@stoplight/json-schema-viewer' library may need to update its package.json or typings.

Expected Behavior

I can import the library.

Possible Workaround/Solution

This seems to be related to: microsoft/TypeScript#52363

In another project, I have the following in my package.json. Something like this should be sufficient.

{
  "name": "package",
  "type": "module",
  "...": "...",
  "exports": {
    ".": {
      "types": "./src/index.ts",
      "default": "./dist/index.js"
    },
    "./example": {
      "types": "./src/example.ts",
      "default": "./dist/example.js"
    }
  }
}

Steps to Reproduce

  1. tsconfig.json with the following:

    {
      "compilerOptions": {
        "moduleResolution": "Bundler",
      },
    }
  2. Import the dependency:

    import {} from '@stoplight/json-schema-viewer'

Environment

TypeScript 5.5.3

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

No branches or pull requests

1 participant