Skip to content

TypeScript cannot find .d.ts when using moduleResolution: NodeNext #5

@NWilson

Description

@NWilson

I recently updated my tsconfig to use moduleResolution: NodeNext (which enables "exports" processing in package.json).

However, I am still producing CommonJS output using "module: NodeNext" in tsconfig with "type: commonjs".

This causes TypeScript to load the "require" branch in your exports, which has no typings:

"exports": {
    ".": {
      "require": "./lib/sha256-uint8array.js",
      "import": {
        "types": "./types/sha256-uint8array.d.ts",
        "default": "./dist/sha256-uint8array.mjs"
      }
    }
  },

You should export the typings for both require&import clients as follows:

"exports": {
    ".": {
      "types": "./types/sha256-uint8array.d.ts",
      "require": "./lib/sha256-uint8array.js",
      "import": "./dist/sha256-uint8array.mjs"
    }
  },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions