Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types not exported correctly? #10

Closed
magnattic opened this issue Jun 21, 2023 · 1 comment · Fixed by #11
Closed

Types not exported correctly? #10

magnattic opened this issue Jun 21, 2023 · 1 comment · Fixed by #11
Assignees
Labels
bug Something isn't working

Comments

@magnattic
Copy link
Contributor

Bug description

When importing this into a TS file, I get the following warning by typescript:
image

Could not find a declaration file for module
myproject/node_modules/.pnpm/[email protected]/node_modules/vitest-fail-on-console/dist/vitest-fail-on-console.es.js implicitly has an any type.
There are types at myproject/node_modules/vitest-fail-on-console/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'vitest-fail-on-console library may need to update its package.json or typings.

Description

I think the problem might be that you define your package.json like this:

  "exports": {
    ".": {
      "import": "./dist/vitest-fail-on-console.es.js",
      "require": "./dist/vitest-fail-on-console.umd.js"
    }
  },
  "types": "./dist/index.d.ts",

This could solve it:

  "exports": {
    ".": {
      "import": "./dist/vitest-fail-on-console.es.js",
      "require": "./dist/vitest-fail-on-console.umd.js",
      "types": "./dist/index.d.ts",
    }
   "types": "./dist/index.d.ts",
  },

Expected outcome

No type errors.

More info

Check out this thread: microsoft/TypeScript#52363
And this helpful tool to check if it's set up correctly: https://arethetypeswrong.github.io/?p=vitest-fail-on-console%400.4.0

@magnattic magnattic added the bug Something isn't working label Jun 21, 2023
magnattic added a commit to magnattic/vitest-fail-on-console that referenced this issue Jun 22, 2023
@magnattic magnattic mentioned this issue Jun 22, 2023
6 tasks
thomasbrodusch pushed a commit that referenced this issue Jun 23, 2023
@thomasbrodusch
Copy link
Owner

Thanks and congrats for your first PR on the repo @magnattic 🥳
New version v0.4.1 including your fix now available on NPM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants