javascript - Cannot find name of module loaded with require() -
i pulling in javascript file @ top of react file (i using typescript way):
let flodialog = require('../public/js/flo-dialog.min'); then there property dialog class:
dialog: flodialog = null; notice type should flodialog. name of prototype object contained in module.
then in constructor initialize dialog so:
constructor() { super(); this.dialog = new flodialog({ effect: { fade: true }, position: 'fixed' }); } and later on call function on dialog prototype object open dialog. code work, but getting typescript error: ts2304: cannot find name 'flodialog'. on dialog: flodialog = null; line.
the module file looks this:
var flodialog=function(t){this.id=date.now(),this.cloak=this.rendercloakhtml()...etc..etc... (minified code) if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { module.exports = flodialog; } so export prototype object module. include require() function. why isn't type recognized on line dialog: flodialog = null; , how fix it?
the type flodialog not defined. don't have ../public/js/flo-dialog.min.d.ts describe should like.
Comments
Post a Comment