We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Got a function from here: https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript And TS says there is an error, not sure if it is true. And in case this is not an error, but ts does count this as error - is there any way to @Suppress it? Thanks.
TypeScript Version: 2.3.2 / but same in playground: https://www.typescriptlang.org/play/index.html
Code
function uuidv4() { return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) ) }
Expected behavior: No error? Actual behavior: Operator '+' cannot be applied to types 'number[]' and '-1000'.
Operator '+' cannot be applied to types 'number[]' and '-1000'.
The text was updated successfully, but these errors were encountered:
This is not a support forum.
Questions should be asked at StackOverflow or on Gitter.im.
But... TypeScript is protecting you from implicit coercion, so you need to cast the array literal:
function uuidv4() { - return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => + return ([1e7] as any + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16) ) }
Sorry, something went wrong.
No branches or pull requests
Got a function from here:
https://stackoverflow.com/questions/105034/create-guid-uuid-in-javascript
And TS says there is an error, not sure if it is true.
And in case this is not an error, but ts does count this as error - is there any way to @Suppress it?
Thanks.
TypeScript Version: 2.3.2 / but same in playground: https://www.typescriptlang.org/play/index.html
Code
Expected behavior:
No error?
Actual behavior:
Operator '+' cannot be applied to types 'number[]' and '-1000'.
The text was updated successfully, but these errors were encountered: