TypeScript definitions not working #121
Replies: 3 comments 1 reply
-
Do you have a snippet you can show where you are attempting to type and it is failing? I personally code almost exclusively in typescript except when porting my demos back to the VanillaJS for examples or asking assistance on this discussion forum. For stock typescript (TSC) should only be required to import the Jolt namespace from the NPM package to access the types. import Jolt from 'jolt-physics'
export type JVec3 = Jolt.Vec3 | Jolt.RVec3;
export const SetJoltVec3 = (vec3: Vector3, jVec3: Jolt.Vec3) => {
jVec3.Set(vec3.x, vec3.y, vec3.z)
return jVec3;
}
export const SetJoltRVec3 = (vec3: Vector3, jVec3: Jolt.RVec3) => {
jVec3.Set(vec3.x, vec3.y, vec3.z)
return jVec3;
}
export const GetJoltVec3 = (jVec3: JVec3, vec3: Vector3) => {
vec3.set(jVec3.GetX(), jVec3.GetY(), jVec3.GetZ())
return vec3;
} I use it more in the following: There are Vite specific issues that I had to work around regarding Vite's packing caching and the package.json declarations, and I do not know if those extend to other ESBuild based compiles, since esbuild rolls its own typescript compiling. I worked around this EsBuild issue by importing the actual library in a JS file and then adding my own *.d.ts definition, and also modified the corresponding JS file so that it supporting supplying arbitrary Jolt modules so projects using the typescript could supply their own via loading from an external url or their local host or Wasm-compat or Wasm file. |
Beta Was this translation helpful? Give feedback.
-
I was able to figure my situation out. I'm working on off of a fork that has some modifications that made using explicit types more difficult. Thanks for the help |
Beta Was this translation helpful? Give feedback.
-
@PhoenixIllusion can I ask what the Vite specific issues that you had to deal with were? I'm running into an issue right now where the default
to
and add the |
Beta Was this translation helpful? Give feedback.
-
Whenever I try to use the typescript types, I can't explicitly state the type of a variable or use the type in any way. Even with the closest I've gotten, it just says its missing prototype functions. Has anyone else been able to successfully explicitly type variables?
Beta Was this translation helpful? Give feedback.
All reactions