Closed jeremiasjutz closed 6 months ago
Emm.. I personally haven't encountered this issue before. Would you mind showing your vite config setup? Hopefully, we can find something there. 🤔
Just wanted to chime in and add that I ran into the same issue just now. Will investigate here shortly.
@jeremiasjutz Make sure strictNullChecks is false in tsconfig.json.
Also, the latest version of @types/three is 0.157.2, while the latest version of three is 0.157.0. Downgrading to @types/three@0.157.0 to match the three version fixed most of the problems (so far).
Though I'm trying to figure out why it's complaining that "'Ecctrl' cannot be used as a JSX component." I can see in the source that it's a default export, so that shouldn't be a problem. I'm guessing maybe it has something to do with ejs vs cjs modules or whatnot.
export * from ../src/Ecctrl.tsx
was the problem in Ecctrl.d.ts. Generating an actual type declaration file using tsc fixed the problem. Not sure which configuration is tripping it up, but will look at it later.
Thanks for your quick replies! I added strictNullChecks to my tsconfig.json and now most of the errors have disappeared. I only get 3 errors now:
> tsc && vite build
node_modules/.pnpm/ecctrl@1.0.36_@react-three+fiber@8.15.4_@types+react-dom@18.2.14_@types+react@18.2.31_@types+_khx5ir5ed2ombljuz23i2atgs4/node_modules/ecctrl/src/Ecctrl.tsx:88:9 - error TS6133: 'jumpLandAnimation' is declared but its value is never read.
88 const jumpLandAnimation = !animated
~~~~~~~~~~~~~~~~~
node_modules/.pnpm/ecctrl@1.0.36_@react-three+fiber@8.15.4_@types+react-dom@18.2.14_@types+react@18.2.31_@types+_khx5ir5ed2ombljuz23i2atgs4/node_modules/ecctrl/src/Ecctrl.tsx:384:18 - error TS6133: 'followCam' is declared but its value is never read.
384 const { pivot, followCam, cameraCollisionDetect } =
~~~~~~~~~
node_modules/.pnpm/ecctrl@1.0.36_@react-three+fiber@8.15.4_@types+react-dom@18.2.14_@types+react@18.2.31_@types+_khx5ir5ed2ombljuz23i2atgs4/node_modules/ecctrl/src/EcctrlAnimation.tsx:5:27 - error TS2307: Cannot find module 'three/examples/jsm/loaders/GLTFLoader' or its corresponding type declarations.
5 import type { GLTF } from "three/examples/jsm/loaders/GLTFLoader";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 3 errors in 2 files.
Errors Files
2 node_modules/.pnpm/ecctrl@1.0.36_@react-three+fiber@8.15.4_@types+react-dom@18.2.14_@types+react@18.2.31_@types+_khx5ir5ed2ombljuz23i2atgs4/node_modules/ecctrl/src/Ecctrl.tsx:88
1 node_modules/.pnpm/ecctrl@1.0.36_@react-three+fiber@8.15.4_@types+react-dom@18.2.14_@types+react@18.2.31_@types+_khx5ir5ed2ombljuz23i2atgs4/node_modules/ecctrl/src/EcctrlAnimation.tsx:5
ELIFECYCLE Command failed with exit code 2.
my tsconfig:
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"strictNullChecks": false,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
my package.json:
{
"name": "game",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@react-three/drei": "^9.88.5",
"@react-three/fiber": "^8.15.4",
"@react-three/rapier": "^1.1.2",
"ecctrl": "^1.0.36",
"leva": "^0.9.35",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"three": "^0.157.0"
},
"devDependencies": {
"@types/react": "^18.2.31",
"@types/react-dom": "^18.2.14",
"@types/three": "^0.157.0",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"@vitejs/plugin-react-swc": "^3.4.0",
"autoprefixer": "^10.4.16",
"eslint": "^8.52.0",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-react-refresh": "^0.4.3",
"postcss": "^8.4.31",
"prettier": "^3.0.3",
"prettier-plugin-organize-imports": "^3.2.3",
"prettier-plugin-tailwindcss": "^0.5.6",
"r3f-perf": "^7.1.2",
"tailwindcss": "^3.3.3",
"three-stdlib": "^2.28.0",
"typescript": "^5.2.2",
"vite": "^4.5.0"
}
}
Any update on this?
@jeremiasjutz, give version 1.0.41 a try. Hopefully, that issue has been fixed 😅
Using Ecctrl in my Next 14 project, I am getting the following ts error:
Unhandled Runtime Error TypeError: object null is not iterable (cannot read property Symbol(Symbol.iterator))
Also getting this error on the <Ecctrl />
component
JSX element type 'Ecctrl' does not have any construct or call signatures.ts(2604) 'Ecctrl' cannot be used as a JSX component.
This is my code:
import PlayerModel from './Player.model';
import Ecctrl from 'ecctrl';
import { useMemo } from 'react';
enum Controls {
forward = 'forward',
backward = 'backward',
leftward = 'leftward',
rightward = 'rightward',
jump = 'jump',
run = 'run',
}
const Player = () => {
/**
* Keyboard control preset
*/
const keyboardMap = useMemo<KeyboardControlsEntry<Controls>[]>(
() => [
{ name: Controls.forward, keys: ['ArrowUp', 'KeyW'] },
{ name: Controls.backward, keys: ['ArrowDown', 'KeyS'] },
{ name: Controls.leftward, keys: ['ArrowLeft', 'KeyA'] },
{ name: Controls.rightward, keys: ['ArrowRight', 'KeyD'] },
{ name: Controls.jump, keys: ['Space'] },
{ name: Controls.run, keys: ['Shift'] },
],
[],
);
return (
<KeyboardControls map={keyboardMap}>
{/* @ts-ignore */}
<Ecctrl debug>
<PlayerModel />
</Ecctrl>
</KeyboardControls>
);
};
export default Player;
Package versions:
"@react-three/drei": "^9.88.11",
"@react-three/fiber": "^8.15.9",
"@react-three/postprocessing": "^2.15.10",
"@react-three/rapier": "^1.1.2",
"ecctrl": "^1.0.41",
"three": "^0.158.0",
"@types/three": "^0.158.0"
Call Stack:
React
node_modules/ecctrl/node_modules/@react-three/drei/web/KeyboardControls.js (100:28)
useKeyboardControls
node_modules/ecctrl/dist/Ecctrl.js (575:54)
renderWithHooks
node_modules/react-reconciler/cjs/react-reconciler.development.js (7363:0)
updateForwardRef
node_modules/react-reconciler/cjs/react-reconciler.development.js (11457:0)
beginWork
node_modules/react-reconciler/cjs/react-reconciler.development.js (13880:0)
beginWork$1
node_modules/react-reconciler/cjs/react-reconciler.development.js (19513:0)
performUnitOfWork
node_modules/react-reconciler/cjs/react-reconciler.development.js (18686:0)
workLoopSync
node_modules/react-reconciler/cjs/react-reconciler.development.js (18597:0)
renderRootSync
node_modules/react-reconciler/cjs/react-reconciler.development.js (18565:0)
recoverFromConcurrentError
node_modules/react-reconciler/cjs/react-reconciler.development.js (17948:0)
performConcurrentWorkOnRoot
node_modules/react-reconciler/cjs/react-reconciler.development.js (17848:0)
@tomasgrusz , not quite sure why 🤔. Maybe try Next version 13.4.19, see if that works?
I have a very simple grid based game that uses
ecctrl
. Sadly my (vite) builds don't work astsc
always errors on ecctrl (even withskipLibCheck: true
).This is my code:
Am I doing something wrong?
Here is the error log when trying to build: