Create GUID in TypeScript - function is valid in JS but not TS
I'm trying to use the solution posted here to create a GUID-type string in my angular4/TypeScript web app.
Here is the function I'm writing:
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
}
console.log(uuidv4())
TypeScript is giving me the following error:
Operator '+' cannot be applied to types 'number[]' and '-1000'.
What do I need to change to make this TS compatible?
Thanks!