node-alea icon indicating copy to clipboard operation
node-alea copied to clipboard

Typescript error

Open eranimo opened this issue 6 years ago • 2 comments

Only a void function can be called with the 'new' keyword.

The typescript definition file appears to be invalid

eranimo avatar Oct 13 '18 20:10 eranimo

As a workaround I am doing this:

import * as alea from 'alea';

interface PrngFactory {
  new(seed?: string): () => number;
}

const Alea: PrngFactory = (alea as unknown) as PrngFactory;

let prng = new Alea('foo'); // no errors

StickyCube avatar Feb 06 '19 22:02 StickyCube

you can just call Alea as a normal function, i.e. just Alea('foo') without the new keyword

SheepTester avatar Jul 05 '24 01:07 SheepTester