Skip to content
New issue

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

@types/uuid references @types/node #328

Closed
sam-s4s opened this issue Sep 23, 2019 · 6 comments · Fixed by DefinitelyTyped/DefinitelyTyped#41814 or DefinitelyTyped/DefinitelyTyped#42438
Milestone

Comments

@sam-s4s
Copy link

sam-s4s commented Sep 23, 2019

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...

@ctavan
Copy link
Member

ctavan commented Sep 23, 2019

@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?

@ctavan ctavan added this to the es-modules milestone Sep 23, 2019
@sam-s4s
Copy link
Author

sam-s4s commented Sep 23, 2019

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!

@ctavan ctavan modified the milestones: es-modules, 4.0.0 Oct 19, 2019
@ctavan ctavan mentioned this issue Oct 31, 2019
10 tasks
@RichardLindhout
Copy link

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() {}
}

@MattyBalaam
Copy link

A warning that this change has broken Typescript in our app! More info here: DefinitelyTyped/DefinitelyTyped#41814 (comment)

@sam-s4s
Copy link
Author

sam-s4s commented Jan 31, 2020

Thank you for doing this - my problem is solved <3

@ctavan
Copy link
Member

ctavan commented Feb 25, 2020

@types/uuid@7.0.0 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants