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
Add LastArrayElement
, Split
, and Trim
types
#159
Conversation
I struggle to see where I would use |
// @mmkal In case you would be willing to help review. |
Co-authored-by: Sindre Sorhus <sindresorhus@gmail.com>
…-fest into query-selector
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.
I can see valid userland use cases for LastArrayElement
, maybe getting the last argument from a function? e.g. type MyFuncOptions = LastArrayElement<Parameters<typeof myFunc>>
Co-authored-by: Misha Kaletsky <15040698+mmkal@users.noreply.github.com>
Co-authored-by: Misha Kaletsky <15040698+mmkal@users.noreply.github.com>
Co-authored-by: Misha Kaletsky <15040698+mmkal@users.noreply.github.com>
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.
Sorry to keep submitting separate reviews! Won't have much chance to look today after this.
I don’t think QuerySelector needs to be part of type-fest. The original author of those types already published and improved on them: https://github.com/g-plane/typed-query-selector |
I agree with @fregante. That package does it better than what we're doing here. I still think the other types added here are useful though. @kainiedziela Would you be able to remove the |
QueryResult
, Split
, TakeLast
and Trim
typesSplit
, TakeLast
and Trim
types
There you go! |
Split
, TakeLast
and Trim
typesLastArrayElement
, Split
, and Trim
types
Fixes #148
Split
Represents an array of strings split using a passed-in character or character set.
Use case: defining the return type of the
String.prototype.split
method.TakeLast
Extracts the type of the last element of an array.
Use case: Defining the return type of functions that extract the last element of an array, for example lodash.last.
Trim
Removes spaces from the edges of a string.