- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
// @strict: true
// @lib: es2020
// @declaration: true
type BadFlatArray<Arr, Depth extends number> = {
obj: {
"done": Arr,
"recur": Arr extends ReadonlyArray<infer InnerArr>
? BadFlatArray<InnerArr, [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20][Depth]>
: Arr
}[Depth extends -1 ? "done" : "recur"]
}["obj"];
declare function flat<A, D extends number = 1>(
arr: A,
depth?: D
): BadFlatArray<A, D>[]
function foo<T>(arr: T[], depth: number) {
return flat(arr, depth);
}
function main() {
foo<number>([1.0, 2.0], 2);
}
ASD_77 16.01.2022 14:28 # 0
ISO 16.01.2022 15:14 # 0
ASD_77 16.01.2022 15:29 # +1
Soul_re@ver 16.01.2022 15:59 # +3
ObeseYoung 16.01.2022 16:49 # +2
ISO 16.01.2022 16:53 # 0
ASD_77 16.01.2022 17:48 # +1
JloJle4Ka 16.01.2022 17:52 # +1
ASD_77 16.01.2022 18:57 # 0
CHayT 16.01.2022 17:59 # +5
CHayT 16.01.2022 18:03 # +6
Оставьте единичку в покое, не надо её растягивать.
j123123 17.01.2022 07:00 # +1