In the the first ts-belt usage example the line:
O.map(N.multiply(10)),
is flagged as being a problem:
Argument of type '(option: Option<number>) => Option<number>' is not assignable to parameter of type '(arg: Option<number>) => Option<0>'.
Type 'Option<number>' is not assignable to type 'Option<0>'.
Type 'number' is not assignable to type 'Option<0>'.
import { A, O, N, pipe } from "@mobily/ts-belt";
pipe(
[1, 2, 3, 4, 5], // → [1, 2, 3, 4, 5]
A.dropExactly(2), // → Some([3, 4, 5])
O.flatMap(A.head), // → Some(3)
O.map(N.multiply(10)), // → Some(30) **************** this line flagged
O.getWithDefault(0) // → 30
); // → 30
The code compiles and runs fine
If I translate the code to ReScript there are no issues:
let result = {
open Belt
let dropExactly = (xs, n) =>
n < 0 || n > Array.length(xs) ? None : Some(Array.sliceToEnd(xs, n))
let head = xs => xs[0]
let multiply = (a, b) => a * b
[1, 2, 3, 4, 5] // → [1, 2, 3, 4, 5]
->dropExactly(2) // → Some([3, 4, 5])
->Option.flatMap(head) // → Some(3)
->Option.map(multiply(10)) // → Some(30) *************** no issue in ReScript
->Option.getWithDefault(0) // → 30
// → 30
}
So is this simply a TypeScript problem/limitation?
In the the first ts-belt usage example the line:
O.map(N.multiply(10)),
is flagged as being a problem:The code compiles and runs fine
If I translate the code to ReScript there are no issues:
So is this simply a TypeScript problem/limitation?