Skip to content
This repository has been archived by the owner on Jan 7, 2024. It is now read-only.

Fixing TypeScript Declaration Issue in 'astro-sanity' Package #28

Open
ps-kate opened this issue Sep 15, 2023 · 3 comments
Open

Fixing TypeScript Declaration Issue in 'astro-sanity' Package #28

ps-kate opened this issue Sep 15, 2023 · 3 comments

Comments

@ps-kate
Copy link

ps-kate commented Sep 15, 2023

Hey there! 👋

I ran into an issue with the 'astro-sanity' package (version 1.1.7) while working on my project. It seems there's a problem with TypeScript type declarations that results in a errors and warnings:

src/pages/posts/index.astro:6:39 - error ts(7016): Could not find a declaration file for module 'astro-sanity'. '/Users/***/Sites/***/node_modules/astro-sanity/dist/astro-sanity.mjs' implicitly has an 'any' type.
  There are types at '/Users/***/Sites/***/node_modules/astro-sanity/dist/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'astro-sanity' library may need to update its package.json or typings.

Here's the fix that worked for me:

diff --git a/node_modules/astro-sanity/package.json b/node_modules/astro-sanity/package.json
index 2b4b11a..5fc451e 100644
--- a/node_modules/astro-sanity/package.json
+++ b/node_modules/astro-sanity/package.json
@@ -10,7 +10,8 @@
   "exports": {
     ".": {
       "import": "./dist/astro-sanity.mjs",
-      "require": "./dist/astro-sanity.js"
+      "require": "./dist/astro-sanity.js",
+      "types": "./dist/index.d.ts"
     }
   },
   "files": [

I've created this pull request to address the issue and help others who might face the same problem. Let's get this fix merged!

Best regards,
Kate

@brandondeweese
Copy link

Issue still exists.

@adstr123
Copy link

Bumping as its happening for me too

@chris-nowicki
Copy link

This is still happening for me as well.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants