egoist / tipc

End-to-end typesafe IPC for Electron
MIT License
179 stars 4 forks source link

Types aren't automatically resolved (could not find declaration file) #4

Closed GeorgeIpsum closed 4 weeks ago

GeorgeIpsum commented 4 months ago

Hi! Love tIPC and am using it internally; however I have to use a patchfile currently for Typescript to not complain about being unable to find type declarations:

diff --git a/package.json b/package.json
index 1b33fbda0307b7d61052108bfffa24e5cfa3aed1..de9c9f8cc8a166dc99293760c312233a79b8f80b 100644
--- a/package.json
+++ b/package.json
@@ -24,11 +24,13 @@
   "exports": {
     "./main": {
       "require": "./dist/main.cjs",
-      "default": "./dist/main.js"
+      "default": "./dist/main.js",
+      "types": "./types/main.d.ts"
     },
     "./renderer": {
       "require": "./dist/renderer.cjs",
-      "default": "./dist/renderer.js"
+      "default": "./dist/renderer.js",
+      "types": "./types/renderer.d.ts"
     },
     "./react-query": {
       "require": "./dist/react-query.cjs",

I'm assuming this is happening because of some quirk with my TSConfig (pasted below); but was wondering if I could add these as a PR.

TSConfigs:

tsconfig.node.json

{
  "compilerOptions": {
    "composite": true,
    "skipLibCheck": true,
    "module": "ESNext",
    "moduleResolution": "bundler",
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "resolveJsonModule": true,
    "baseUrl": ".",
    "paths": {
      "~/*": [
        "./electron/*"
      ]
    }
  },
  "include": [
    "vite.config.ts"
  ]
}

tsconfig.json

{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "lib": [
      "ES2020",
      "DOM",
      "DOM.Iterable"
    ],
    "baseUrl": ".",
    "paths": {
      "~/*": [
        "./src/*"
      ]
    },
    "module": "ESNext",
    "skipLibCheck": true,
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true
  },
  "include": [
    "src",
    "electron",
    "scripts"
  ],
  "references": [
    {
      "path": "./tsconfig.node.json"
    }
  ]
}
egoist commented 4 weeks ago

should be fixed