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

TypeScript Generics #13

Open
dimadeveatii opened this issue Feb 6, 2019 · 1 comment
Open

TypeScript Generics #13

dimadeveatii opened this issue Feb 6, 2019 · 1 comment
Labels
question Further information is requested

Comments

@dimadeveatii
Copy link
Member

Should we cover generics?

@dimadeveatii dimadeveatii added the question Further information is requested label Feb 6, 2019
@badsyntax
Copy link

badsyntax commented Jan 13, 2022

While T might be acceptable when only one generic is used, things get out of hand when multiple generics are used, and i've see people use T,U,D etc which is completely meaningless IMO.

Even the typescript docs now use description generic names: https://www.typescriptlang.org/docs/handbook/2/generics.html

function identity<Type>(arg: Type): Type {
  return arg;
}

Example of hard-to-read code due to single character generics: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/64d939eb39dc7b80b27da1a63774cfca755670f9/types/styled-components/index.d.ts

Example of easy-to-read code due to descriptive generic names: https://github.com/tannerlinsley/react-query/blob/755702dd78efadb66038fb2535b7c513c128a918/src/react/useQuery.ts

As a consumer of both of these types, it's so much easier to work with descriptive generic names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants