Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Typescript node module can't find index.d.ts #2

Copy link
Copy link

Description

@asciibits
Issue body actions

I am writing a TypeScript node module, and getting the following error when using @randomorg/core:

src/util/random.ts:1:31 - error TS7016: Could not find a declaration file for module '@randomorg/core'. '/home/lsanderson/src/minesweeper/node_modules/@randomorg/core/lib/esm/index.js' implicitly has an 'any' type.
  There are types at '/home/lsanderson/src/minesweeper/node_modules/@randomorg/core/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@randomorg/core' library may need to update its package.json or typings.

1 import {RandomOrgClient} from '@randomorg/core';
                                ~~~~~~~~~~~~~~~~~


Found 1 error in src/util/random.ts:1

I can fix this locally by explicitly adding index.d.ts into your package.json, like so:

{
  ...
  "types": "./types/index.d.ts",
  "typings": "./types/index.d.ts",
  "exports": {
    "require": "./lib/index.js",
    "import": "./lib/esm/index.js",
    "types": "./types/index.d.ts"
  },
  ...
}

If you agree this is a good solution, can you please add it? Thanks!

Reactions are currently unavailable

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.