Skip to content

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

@au5ton

Description

@au5ton

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions