waitingsong / node-win32-api

win32 api
MIT License
430 stars 55 forks source link

Could not find a declaration file for module 'win32-api/promise' #48

Closed xia0hj closed 1 year ago

xia0hj commented 1 year ago

Hello I need some help I get this error when I try to tsc

electron/native/win32.ts:3:24 - error TS7016: Could not find a declaration file for module 'win32-api/promise'. 'C:/my-workspace/demo/electron-demo/node_modules/win32-api/dist  Try `npm i --save-dev @types/win32-api` if it exists or add a new declaration (.d.ts) file containing `declare module 'win32-api/promise';`

3 import { User32 } from 'win32-api/promise';

image

nodejs=16.16.0 typescript=4.9.4 win32-api=20.2.0

My tsconfig.json ↓↓↓

{
  "compilerOptions": {
    "target": "ESNext",
    "useDefineForClassFields": true,
    "lib": ["DOM", "DOM.Iterable", "ESNext"],
    "allowJs": false,
    "skipLibCheck": true,
    "esModuleInterop": false,
    "allowSyntheticDefaultImports": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "module": "ESNext",
    "moduleResolution": "NodeNext",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",
    "baseUrl": "./",
    "paths": {
      "@/*": [
        "src/*"
      ]
    },
  },
  "include": ["src", "electron"],
}
waitingsong commented 1 year ago

提供一个最小复现库我看看? package.json 可能需要添加

"type": "module",

貌似 electron 尚不支持 ESM ?

waitingsong commented 1 year ago

找到原因了,等我发个新版

waitingsong commented 1 year ago

try version 20.4.0

xia0hj commented 1 year ago

谢谢,更新后没有报错了

hengkx commented 1 year ago

same error

waitingsong commented 1 year ago

same error

nodejs version? and content of package.json/tsconfig.json

hengkx commented 1 year ago

node 18,

waitingsong commented 1 year ago

node 18,

提供一个最小复现仓库我看看

waitingsong commented 1 year ago

node 18,

package.json/tsconfig.json ?

hengkx commented 1 year ago

https://electron-react-boilerplate.js.org 用的这个模板