I found this file :
https://www.npmjs.com/package/@types/matter-js
i execute this line :
npm install --save @types/matter-js
In root ts file i got error message :
'Matter' refers to a UMD global, but the current file is a module. Consider adding an import instead.
Code looks like :
///<reference path="matter-js.d.ts"/>
import Ioc from "./libs/ioc";
let master = new Ioc();
console.log(master);
console.log(Matter);
Error in browser:
app.ts:11 Uncaught ReferenceError: Matter is not defined
Did i need to load matter-js.js lib ?
If i put :
import matter from 'matter-js'
i get :
Module ''matter-js'' has no default export.
You can try to load it using import * as matter from 'matter-js'
, that should work.
I load the matter.js library with a script tag. Did you forget that?
<script src="js/matter.min.js"></script>
And I installed the typings with
npm install @types/matter-js
Unfortunately, the typescript lib seems outdated. Last commit 2 years ago. Parameters that should be optional are instead required in the typescript definitions...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With