Unfortunately I'm trying to use this library with Typescript, so I need to use @types/uuid, but that contains a reference to Buffer in globals.d.ts which means it pulls in @types/node, which breaks my build. I'm writing code for browsers, not node.
There would be a few possible fixes for this, including just removing the reference to Buffer and just using Array / ArrayLike - or creating an interface for Buffer instead of pulling in the one from node...
@sam-s4s thanks for reporting this.
I am currently trying to make this library esmodule ready and in the process I also want to improve TypeScript support.
Could you provide me with a bit more detailed steps to reproduce or sample code/commands where things fall apart for you?
Oh that would be excellent :)
So the problem for me is purely in the DefinitelyTyped @types/uuid definition from what I can tell. Inside that type it pulls in a reference to @types/node, because of Buffer - which is located in the node globals.d.ts.
But as I'm doing browser development (not making a node app) I can't use anything from here, and the presence of those types breaks things like setTimeout (makes its return type NodeJS.Timer instead of number).
This is a problem that has come up a few times before in other projects, and it's one of the pains of the ecosystem :( It normally just requires someone to sort of the types to remove that dependency.
Let me know if you need any more info, and thank you for the reply!
If you have a create-react-app
put the following in yourreact-app-env.d.ts file
declare module 'uuid/v4' {
export default function uuid() {}
}
A warning that this change has broken Typescript in our app! More info here: https://github.com/DefinitelyTyped/DefinitelyTyped/pull/41814#issuecomment-580763714
Thank you for doing this - my problem is solved <3
@types/[email protected] has finally been released and should fix this issue. Feel free to create a new issue if you feel that this problem has not been solved yet.
Most helpful comment
Oh that would be excellent :)
So the problem for me is purely in the DefinitelyTyped
@types/uuiddefinition from what I can tell. Inside that type it pulls in a reference to @types/node, because ofBuffer- which is located in the node globals.d.ts.But as I'm doing browser development (not making a node app) I can't use anything from here, and the presence of those types breaks things like
setTimeout(makes its return typeNodeJS.Timerinstead ofnumber).This is a problem that has come up a few times before in other projects, and it's one of the pains of the ecosystem :( It normally just requires someone to sort of the types to remove that dependency.
Let me know if you need any more info, and thank you for the reply!