Skip to content

fix: missing types entry in package exports#42

Open
jcwillox wants to merge 1 commit intojonschlinkert:masterfrom
jcwillox:patch-1
Open

fix: missing types entry in package exports#42
jcwillox wants to merge 1 commit intojonschlinkert:masterfrom
jcwillox:patch-1

Conversation

@jcwillox
Copy link
Copy Markdown

Typescript complains it can't find the types when using ESM, so I updated the exports config to include types and it stopped complaining 👍. With this change type checking and bundling now works in ESM projects (or I guess newer node versions/typescript versions that support exports).

@ybiquitous
Copy link
Copy Markdown

Hi @jcwillox, this PR seems to duplicate with #28 :)

@jcwillox
Copy link
Copy Markdown
Author

Oh yeah it is, didn't see that before 👀, the other one is probably more correct with the cts and mts types, although the combined one works too.

Copy link
Copy Markdown

@typed-sigterm typed-sigterm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The missing types does indeed cause errors in VS Code.

Could not find a declaration file for module 'is-plain-object'. '.../node_modules/is-plain-object/dist/is-plain-object.mjs' implicitly has an 'any' type.
  There are types at '.../node_modules/is-plain-object/is-plain-object.d.ts', but this result could not be resolved when respecting package.json "exports". The 'is-plain-object' library may need to update its package.json or typings.

@chimurai
Copy link
Copy Markdown

Would be nice to have this PR merged.

Getting the same error due the missing export types when using the new typescript-go preview (v7) (https://www.npmjs.com/package/@typescript/native-preview)

tsgo error:

error TS2307: Cannot find module 'is-plain-object' or its corresponding type declarations.

1 import { isPlainObject } from 'is-plain-object';
                                ~~~~~~~~~~~~~~~~~

More projects facing similar issue in this thread:
microsoft/typescript-go#518

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants