I've been developing an app to enhance my understanding of TypeScript. It functions perfectly in Chrome, however, I encounter a problem when running it in Edge. The issue lies within this method:
set position(pos: Point) {
const diffAsPoint = pos.minus(this.canvasPos);
let diff: Vector2D = diffAsPoint.toVector2D(); // <--- this line
if (diff instanceof Vector2D) {
console.info("is a vector!");
} else {
console.info("not a vector!");
}
Occasionally, I notice that diff IS a Vector2D
rather than being an instance of a Vector2D
. This leads to errors such as 'Object doesn't support property or method ...'
https://i.sstatic.net/kZPQf.png
The toVector2D
method is quite simple:
toVector2D(): Vector2D {
return new Vector2D(this.x, this.y);
}
In case it matters, here's some context:
the app is a game running in a loop (60 frames per second - utilizing
)window.requestAnimationFrame(() => this.animloop());
it performs well in Chrome
it encounters issues in IE (though with different symptoms, debugging proves challenging as the tools crash)
latest TypeScript version (2.2.1) is utilized
errors occur randomly after startup, ranging from 2-3 seconds into execution
similar occurrences happen elsewhere in the code related to
Point
andVector2D
, seemingly linked to creating them each frame (some problems are resolved by introducing a field instead of creating one each frame)AMD and requirejs are employed
UPDATE -------
Upon further examination using Edge and debug tools with 'Always refresh from server' enabled, while loading from the website (), it becomes apparent that the game tries to initiate before all modules are fully loaded. In contrast, Chrome appears to wait for complete loading before executing the game.
Any suggestions or insights?