Multiple errors using demo source code in Typescript
See original GitHub issueI copied this code from the gravity demo to add mouse control in my typescript program
// add mouse control
var mouse = Mouse.create(render.canvas),
mouseConstraint = MouseConstraint.create(engine, {
mouse: mouse,
constraint: {
stiffness: 0.2,
render: {
visible: false
}
}
});
Composite.add(world, mouseConstraint);
// keep the mouse in sync with rendering
render.mouse = mouse;
and got the following 3 errors:
Type ‘{ stiffness: number; render: { visible: false; }; }’ is missing the following properties from type ‘Constraint’: bodyA, bodyB, id, label, and 5 more.
Argument of type ‘MouseConstraint’ is not assignable to parameter of type ‘Body | Composite | Constraint’. Type ‘MouseConstraint’ is missing the following properties from type ‘Body’: angle, angularSpeed, angularVelocity, area, and 30 more.
Property ‘mouse’ does not exist on type ‘Render’.
I don’t see any easy workaround to using this mouse functionality in typescript.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
TypeScript errors and how to fix them
Common Errors Below you find a list of common TypeScript errors along with the buggy code and its fixed version.
Read more >Complete list of Typescript error codes and their fixes
Looking at the 1.6.2 sources of the compiler, tsc.js , tsserver.js , typescript.js and typescriptServices.js , a variable called ts.
Read more >Documentation - Understanding Errors - TypeScript
Let's work through some examples to see how they work in practice. Here's an example that produces an error message longer than the...
Read more >Improving TypeScript error handling with exhaustive type ...
Discover an improved method for handling errors in TypeScript that solves problems that arise from returning null and throwing try...catch.
Read more >How to solve too many try catch in Typescript ? - GeeksforGeeks
Example -1: In this example, we will create multiple try/catch blocks in order to catch multiple errors from different functions which actually ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t maintain the TypeScript bindings so I can’t help much (they’re a separate project) but if there’s any TypeScript users willing to help them out, I think they take contributions.
That worked! this is how my code ended up looking! thanks