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 · 1 comment · May be fixed by stoplightio/scripts#131

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

@Roman3349
Copy link

Roman3349 commented Feb 25, 2025

It is caused by incorrect information in package.json. Property exports replaces properties main, module and typing (which contains also invalid path), but all mentioned properties are defined.

Fixed in stoplightio/scripts#131.

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