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

How to fix index.mjs' implicitly has an 'any' type? #50

Closed
biplobsd opened this issue Jul 17, 2023 · 4 comments
Closed

How to fix index.mjs' implicitly has an 'any' type? #50

biplobsd opened this issue Jul 17, 2023 · 4 comments
Labels
bug Something isn't working version 2.x

Comments

@biplobsd
Copy link

After npm install npm install -D @macfja/svelte-persistent-store I get this error.
I also restart VSCode but error still rise.

Error text:

Could not find a declaration file for module '@macfja/svelte-persistent-store'. 'g:/project/as/node_modules/@macfja/svelte-persistent-store/dist/index.mjs' implicitly has an 'any' type.
  There are types at 'g:/project/as/node_modules/@macfja/svelte-persistent-store/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@macfja/svelte-persistent-store' library may need to update its package.json or typings.ts(7016)

Here is a screenshot below

image

@MacFJA MacFJA added bug Something isn't working version 2.x labels Jul 17, 2023
@MacFJA
Copy link
Owner

MacFJA commented Jul 17, 2023

That's very strange:

  • package.json declare a types node
  • the types node is pointing to types/index.d.ts
  • the file types/index.d.ts exist
  • the file types/index.d.ts export writable from ./alias
  • the file types/alias.d.ts exist
  • the file types/alias.d.ts export the definition of writable

I should have miss something

@MacFJA
Copy link
Owner

MacFJA commented Jul 17, 2023

After some quick test, it seems that declaring the types in the exports works.

Look like we can't have both exports and types at the root of the package.json
The documentation indicate that be default Typescript search for a declaration in the same directory of the imported file, but it don't indicate that types (at root level of package.json) is not used as a fallback


I will update teh lib to add types inside the exports node

@biplobsd
Copy link
Author

I'll waiting for this.
Currently I just ignored types.. And it is working well...

@MacFJA
Copy link
Owner

MacFJA commented Jul 21, 2023

I just publish the version 2.3.2 that should solve the typing issue

@MacFJA MacFJA closed this as completed Jul 21, 2023
biplobsd added a commit to biplobsd/as that referenced this issue Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working version 2.x
Projects
None yet
Development

No branches or pull requests

2 participants