“找不到模块’@handsontable/react’的声明文件”,尽管存在’d.ts’文件。

huangapple go评论111阅读模式
英文:

"Could not find a declaration file for module '@handsontable/react'" even though "d.ts" file exists

问题

以下是您要翻译的内容:

"I'm starting a new project with vite+react+ts+swc with below command following vite document.

npm create vite@latest -- --template react-swc-ts

And, I installed handsontable library with below command. (It also written in handsontable document.)

npm install --save handsontable @handsontable/react

However, When I try to use handsontable in my App.tsx file, It occurs two typescript errors.

// App.tsx 
import { HotTable } from '@handsontable/react'; 
import { registerAllModules } from 'handsontable/registry';
src/App.tsx:6:26 - error TS7016: Could not find a declaration file for module '@handsontable/react'. '../node_modules/@handsontable/react/es/react-handsontable.mjs' implicitly has an 'any' type.
  There are types at '../node_modules/@handsontable/react/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@handsontable/react' library may need to update its package.json or typings.


src/App.tsx:7:36 - error TS7016: Could not find a declaration file for module 'handsontable/registry'. '../node_modules/handsontable/registry.mjs' implicitly has an 'any' type.
  There are types at '../node_modules/handsontable/registry.d.ts', but this result could not be resolved when respecting package.json "exports". The 'handsontable' library may need to update its package.json or typings.

Here is my tsconfig.json. (created by vite template)

{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true
  },
  "include": ["src"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

And I think there is no problem with handsontable library because it has index.d.ts normally."

英文:

I'm starting a new project with vite+react+ts+swc with below command following vite document.

npm create vite@latest -- --template react-swc-ts

And, I installed handsontable library with below command. (It also written in handsontable document.)

npm install --save handsontable @handsontable/react

However, When I try to use handsontable in my App.tsx file, It occurs two typescript errors.

// App.tsx
import { HotTable } from '@handsontable/react';
import { registerAllModules } from 'handsontable/registry';
src/App.tsx:6:26 - error TS7016: Could not find a declaration file for module '@handsontable/react'. '.../node_modules/@handsontable/react/es/react-handsontable.mjs' implicitly has an 'any' type.
  There are types at '.../node_modules/@handsontable/react/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@handsontable/react' library may need to update its package.json or typings.


src/App.tsx:7:36 - error TS7016: Could not find a declaration file for module 'handsontable/registry'. '.../node_modules/handsontable/registry.mjs' implicitly has an 'any' type.
  There are types at '.../node_modules/handsontable/registry.d.ts', but this result could not be resolved when respecting package.json "exports". The 'handsontable' library may need to update its package.json or typings.

Here is my tsconfig.json. (created by vite template)

{
  "compilerOptions": {
    "target": "ES2020",
    "useDefineForClassFields": true,
    "lib": ["ES2020", "DOM", "DOM.Iterable"],
    "module": "ESNext",
    "skipLibCheck": true,

    /* Bundler mode */
    "moduleResolution": "bundler",
    "allowImportingTsExtensions": true,
    "resolveJsonModule": true,
    "isolatedModules": true,
    "noEmit": true,
    "jsx": "react-jsx",

    /* Linting */
    "strict": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noFallthroughCasesInSwitch": true
  },
  "include": ["src"],
  "references": [{ "path": "./tsconfig.node.json" }]
}

And I think there is no problem with handsontable library because it has index.d.ts normally.

答案1

得分: 0

这是Handsontable库中的一个错误。

https://github.com/handsontable/handsontable/issues/10448

英文:

It was a bug in the Handsontable library.

https://github.com/handsontable/handsontable/issues/10448

huangapple
  • 本文由 发表于 2023年7月17日 20:14:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76704362.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定