[Bug] Encountering TS Errors When Using @kintone/rest-api-client in Vite
GuSanle opened this issue · 4 comments
Summary
In projects built with Vite4, using the @kintone/rest-api-client results in a TS error.
This occurs regardless of whether the Vue template or the React template is used.
Target Package
@kintone/rest-api-client
Target Version
4.1.0
Reproduction
- npm create vite@latest vite-kintone-api
- choose react and ts
- cd vite-kintone-api
- npm install
- npm install @kintone/rest-api-client
- use in main.ts
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.tsx'
import './index.css'
import { KintoneRestAPIClient } from "@kintone/rest-api-client";
const client = new KintoneRestAPIClient({
baseUrl: "https://example.cybozu.com",
auth: {
username: import.meta.env.VITE_KINTONE_USERNAME,
password: import.meta.env.VITE_KINTONE_PASSWORD,
},
});
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
It will show error
Cannot find module '@kintone/rest-api-client' or its corresponding type declarations.ts(2307)
Expected Behavior
No typescript error
Actual Behavior
It will show typescript error when import { KintoneRestAPIClient } from "@kintone/rest-api-client";
Cannot find module '@kintone/rest-api-client' or its corresponding type declarations.ts(2307)
Environment
System:
OS: macOS 13.5.2
CPU: (10) arm64 Apple M1 Pro
Memory: 311.53 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.5.1 - ~/.nvm/versions/node/v20.5.1/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 9.8.0 - ~/.nvm/versions/node/v20.5.1/bin/npm
Browsers:
Chrome: 117.0.5938.88
Safari: 16.6
npmPackages:
@kintone/rest-api-client: ^4.1.0 => 4.1.0
typescript: ^5.0.2 => 5.2.2
It seems to be due to the latest version of vite changing the value of "moduleResolution" from "Node" to "bundle" (new setting for typescript 5)
online Lint packaging errors check tool:
https://publint.dev/@kintone/rest-api-client@4.1.0