Skip to content

ESM module types do not resolve #1

@robertying-stripe

Description

@robertying-stripe

When using LWWMap via ESM import

import { LWWMap } from "y-lwwmap";

the types from the d.ts file are not respected, and typescript has the following warning:

Could not find a declaration file for module 'y-lwwmap'. 'node_modules/y-lwwmap/dist/LWWMap.esm.js' implicitly has an 'any' type.
  There are types at 'node_modules/y-lwwmap/dist/LWWMap.d.ts', but this result could not be resolved when respecting package.json "exports". The 'y-lwwmap' library may need to update its package.json or typings.ts(7016)

Based on the issue in the ts compiler[0] - it looks like this can be resolved by creating a copy of the types file (.d.ts) that is named LWWMap.esm.d.ts and moving types down a level in package.json[1]

[0]microsoft/TypeScript#52363
[1]https://www.kravchyk.com/typescript-npm-package-json-exports/

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