natemoo-re / micromorph

A very tiny library for diffing DOM nodes

Home Page:https://stackblitz.com/edit/micromorph-demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could not find a declaration file for module

peterhirn opened this issue · comments

There seems to be a problem with the types in package.json.

tsc error:

src/entry-server.tsx(16,17): error TS7016: Could not find a declaration file for module 'micromorph'. 'C:/project/apps/web/node_modules/micromorph/index.mjs' implicitly has an 'any' type.
There are types at 'C:/project/apps/web/node_modules/micromorph/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'micromorph' library may need to update its package.json or typings.

This works for me:

diff --git a/package.json b/package.json
index 3251a6ca39f860b6aeb377afff63b57339a4f24c..b167449d14c777a4a644d9bd427400c794656cf1 100644
--- a/package.json
+++ b/package.json
@@ -2,9 +2,12 @@
   "name": "micromorph",
   "version": "0.4.5",
   "main": "./index.mjs",
-  "types": "./types.d.ts",
+  "types": "./index.d.ts",
   "exports": {
-    ".": "./index.mjs",
+    ".": {
+      "default": "./index.mjs",
+      "types": "./index.d.ts"
+    },
     "./spa": "./dist/spa.js",
     "./nav": "./dist/nav.js"
   },