Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript Errors from /node_modules/ecctrl/src/EcctrlJoystick.tsx #130

Open
trebeljahr opened this issue Feb 11, 2025 · 3 comments · May be fixed by #131
Open

Typescript Errors from /node_modules/ecctrl/src/EcctrlJoystick.tsx #130

trebeljahr opened this issue Feb 11, 2025 · 3 comments · May be fixed by #131

Comments

@trebeljahr
Copy link

When trying to use ecctrl within a next.js project I get a bunch of errors from within node_modules. They look like this:

Type error: Type 'CylinderGeometry' is missing the following properties from type 'BufferGeometry': drawcalls, offsets, addIndex, addDrawCall, and 5 more.

  129 |         <Suspense fallback="null">
  130 |             <animated.group position-x={springs.basePositionX} position-y={springs.basePositionY}>
> 131 |                 <mesh geometry={joystickBaseGeo} material={joystickBaseMaterial} rotation={[-Math.PI / 2, 0, 0]} {...props.joystickBaseProps} />
      |                       ^
  132 |             </animated.group>
  133 |             <animated.group rotation-x={springs.topRotationX} rotation-y={springs.topRotationY}>
  134 |                 <mesh geometry={joystickStickGeo} material={joystickStickMaterial} rotation={[-Math.PI / 2, 0, 0]} position={[0, 0, 1.5]} {...props.joystickStickProps} />

Now the thing that makes me curious is that these happen even though I have skipLibCheck set to true within my tsconfig... Still I get errors from node_modules? My tsconfig for reference:

{
  "compilerOptions": {
    "module": "esnext",
    "target": "es2017",
    "jsx": "preserve",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "strictNullChecks": false,
    "forceConsistentCasingInFileNames": true,
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "noEmit": true,
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "incremental": true,
    "baseUrl": ".",
  },
  "exclude": ["node_modules"],
  "include": [
    "next-env.d.ts",
    "**/*.d.ts",
    "**/*.ts",
    "**/*.tsx",
  ]
}

However, after some digging, I saw that the file those errors are from is not a .d.ts file => it's a .tsx file... and hence not covered by skipLibCheck.

Looking at the ecctrl/dist/Ecctrl.d.ts I think I might have found the culprit for this:

import { RapierRigidBody, type RigidBodyProps } from "@react-three/rapier";
import { type ReactNode } from "react";
import React from "react";
export { EcctrlAnimation } from "./EcctrlAnimation";
export { useFollowCam } from "./hooks/useFollowCam";
export { useGame } from "./stores/useGame";
export { EcctrlJoystick } from "../src/EcctrlJoystick";
export { useJoystickControls } from "./stores/useJoystickControls";
declare const _default: React.ForwardRefExoticComponent<EcctrlProps & React.RefAttributes<CustomEcctrlRigidBody>>;
export default _default;
export type camListenerTargetType = "document" | "domElement";

specifically this line:

export { EcctrlJoystick } from "../src/EcctrlJoystick";

should be

export { EcctrlJoystick } from "./EcctrlJoystick";

not sure where/how these are generated, but it importing from ../src makes type definitions break because it doesn't use the type definitions and instead the "real" .tsx file. Which leads to the inclusion of it into typechecking + the resulting errors. (most likely because of some version/type mismatch between ecctrl three types vs. locally installed three.js version?)

my package.json versions:

{
  "ecctrl": "^1.0.92",
  "@react-three/rapier": "^1.5.0",
  "@react-three/fiber": "^8.17.14",
  "three": "^0.173.0",
}

Related to:
#12
#96
#82
#25

@trebeljahr
Copy link
Author

I think the problem is this line in the src.

export { EcctrlJoystick } from "../src/EcctrlJoystick";

See how the import there is differerent from the other imports like

export { EcctrlAnimation } from "./EcctrlAnimation";

@trebeljahr
Copy link
Author

trebeljahr commented Feb 11, 2025

not sure if changing this will have any other effects, but I think it should just fix the /dist/ because it should then know to use the .d.ts file correctly then.

Happy to open a PR for this as well.

@trebeljahr trebeljahr linked a pull request Feb 11, 2025 that will close this issue
@trebeljahr
Copy link
Author

tested it with npm run build, and the /dist/ folder now looks correct, at least locally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant