Utilizing the rotateByDegrees function from a library called node-poweredup within a typescript project:
motor.rotateByDegrees(20,10).then(function(value) {console.log("test");}, function(value) {console.log("error");});
Expecting to see "test" after successful completion, however, the promise remains unresolved. When using await, it gets stuck on the await line indefinitely. Attempting to replicate the syntax utilized in the rotateByDegrees function:
let promise = new Promise((resolve) => { return resolve(); });
results in a compilation error:
error TS2794: Expected 1 arguments, but got 0. Did you forget to include 'void' in your type argument to 'Promise'?
I can get it to compile and function as anticipated with resolve(true)
, but how is it compiling in the library then? Is my understanding of promises incorrect? Could this be related to a TypeScript feature or possibly a bug in the library? As a newcomer to JavaScript, I want to avoid over-complicating things by including irrelevant information. If you could provide insight into what I might be overlooking and suggestions for debugging this issue, I would be able to offer any necessary details.