-
Notifications
You must be signed in to change notification settings - Fork 15
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
Internal aliasing #90
Conversation
BREAKING CHANGE: No longer exporting Keys<T> either. This alias is too opinionated stylistically and doesn't support good TS practices. If using it, it would be best to include in a per-project basis. Besides, it isn't difficult to write or come up with (`type Keys<T> = keyof T;`), so is outside the scope of this project.
Yeah, good to keep Tangent: you mentioned in the other issue being unhappy with the naming of For export type OverwriteReturn<F extends Function, R> =
F extends ((...x: infer T) => unknown) ? ((...x: T) => R) : never; I had vaguely thought it wasn't kosher, but I haven't been able to break it in the Typescript playground, either. I haven't been able to turn up documentation one way or another. (Mostly because I suck at googling these things: "typescript generic extends Function", "typescript function constructor type constraint" - garbage results, but I don't know how better to phrase the query) The only hint I've found is from the Typescript Do's and Don'ts[1], which says to never
[1] I just noticed that it's "Do's and Don'ts", rather than the consistent "Dos and Don'ts" or the consistent but infuriating "Do's and Don't's". Just felt I had to share that. |
Oh jeez, I had entirely forgotten about
If you have any other names that seem off, do let me know! |
Also I had to read that footnote a few times to catch what was going on 🤣 I knew it had something to do with the single quote placement, but I couldn't quite put my finger on it. |
🎉 This PR is included in version 2.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
@@ -24,8 +22,8 @@ export type IsNumber<T> = T extends number ? True : False; | |||
export type IsString<T> = T extends string ? True : False; | |||
export type IsFunction<T> = | |||
Or< | |||
T extends AnyFunc ? True : False, | |||
T extends Function ? True : False>; // tslint:disable-line | |||
T extends Function ? True : False, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The find/replace made this condition redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Merp. Good catch. Not sure how I missed it on my final scan
Per this discussion, this removes some of the internal aliasing in ST. I decided to kill
Keys<T>
as an export too. It really is a stylistic thing and does not fit in the purview of ST in my opinion. I think ST should strive to be more focused on repetitively useful types (useful as in: can't work without it) and difficult to come up with / write types. Opinionated style choices---like Keys---don't really have as much of a place.I decided to keep ObjectKeys as an export since it is non-obvious why we'd use the
keyof any
syntax. ObjectKeys should have some reasonable documentation explaining the historical relevance (which it doesn't yet), where the major value would be in the documentation instead of in the export itself. This fits the larger goal of making ST also a nice learning tool.I just can't decide on
AnyFunc
. Here are the two options that I can come up with, maybe @Retsam you have a cleaner way of writing this?vs