-
Notifications
You must be signed in to change notification settings - Fork 22
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
flatten (deep) #32
Comments
Hey! Note that these |
Sorry, currently I was very busy at work so don't have time updating the definitions. Hopefully when redirect works we can consolidate the work with DT and get things going for the better. 🌷 |
Hah, quite the coincidence you already had something just like this. :) declare function flatten<T>(array: NestedArray<T>): T[];
interface NestedArray <T> {
[index: number]: T | NestedArray<T>;
length: number;
}
let numbers: number[] = flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]);
// Type '(number | (number | (number | (number | number[])[])[])[])[]' is not assignable to type 'number[]'.
// Type 'number | (number | (number | (number | number[])[])[])[]' is not assignable to type 'number'.
// Type '(number | (number | (number | number[])[])[])[]' is not assignable to type 'number'. That said, priority here is in the order of 'super not urgent' to me. Was just wondering pretty much. |
Hi @blakeembrey. :D
I started checking out the lodash typings looking for inspiration to improve the ramda ones. Definitely learned there! Can't say I envy all the extra lodash wrappers though, and here I thought we had it bad with currying!
So one point I'd still had trouble getting to type correctly there was
flatten
, for which I tried out if thelodash
definition (deep case) might be of help.I tried to test like what'd be as follows in the lodash case:
For me (nightly TS 2.2) this wasn't quite type-checking normally yet; curious if it was functional on your side or if we're in the same boat here for now.
Just figured since we're largely typing similar functions having linked issues up might be of use. That said, there might still be some existing typings in our ramda one that might be of use in further typing lodash as well.
The text was updated successfully, but these errors were encountered: