No reference found on Math.seedrandom(0) even when I included seedrandom in project.

I am trying to use a same random seed for debugging purpose. I am using seedrandom found here.

https://github.com/davidbau/seedrandom

I included the cdn link in script tag and ALT-Enter it to download it.

Now the seedrandom package global. But still the editor shows reference error on Math.seedrandom(0); 

I am not sure how the Math.seedrandom() calls seedrandom package but that's what they did in sample code. here https://github.com/davidbau/seedrandom

The squiggly line just wont go. I even installed seedrandom by npm install and still the problem persists.

Any idea on how to solve this Type error. 

0
1 comment

https://cdnjs.cloudflare.com/ajax/libs/seedrandom/2.4.3/seedrandom.js doesn't add seedrandom to Math namespace; @types\seedrandom\index.d.ts doesn't do this as well  - moreover, the latter is a type definition for seedrandom node modules; and, when using seedrandom installed with npm, you can't use Math.seedrandom(), you should use

var seedrandom = require('seedrandom');
seedrandom();

Math.seedrandom() is here for backward compatibility, the library mutates Math.random when the method is calles this way

So, there is no way for webstorm to resolve Math.seedrandom() during static code analysis

 

0

Please sign in to leave a comment.