Skip to content

Module resolution fails for TypeScript types due to missing "types" in package.json "exports" #242

@CaarLo1337

Description

@CaarLo1337

Updated from 10.23.0 to 11.1.0 and got the following issue

When importing types from 'fsxa-api' in a TypeScript project, an error occurs:

Root Cause
The package.json defines an "exports" field that restricts module resolution to the main entry points (./dist/fsxa-api.es5.js and ./dist/fsxa-api.cjs.js), but does not include a "types" key to specify the TypeScript declaration file. This causes TypeScript's module resolution to respect the exports restriction and fail to access ./dist/types/index.d.ts, even though it's specified in the "types" field.

https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports

Suggested Fix
Update the "exports" field in package.json to include types:

"exports": {
  ".": {
    "types": "./dist/types/index.d.ts",
    "import": "./dist/fsxa-api.es5.js",
    "require": "./dist/fsxa-api.cjs.js"
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions