emmanueltouzery / prelude-ts

Functional programming, immutable collections and FP constructs for typescript and javascript
ISC License
377 stars 21 forks source link

experiments with more precise option types. impressive sometimes but … #2

Closed winbuzz2523 closed 6 years ago

winbuzz2523 commented 6 years ago

…two gotchas mean i don't want it in master for now:

let x: number|undefined; const y = Option.of(x);

=> Inferred to Some<number|undefined> <-- i never want that type!

Need Option.from(x) to make it work.

another one:

List.of(Option.of(5), Option.none())

doesn't compile anymore. It says None is not compatible with Some.

Need List.of<Option> to make it work.

Also generally speaking I'm not sure it brings much apart from simple demos (and making super nice apidocs) -- in the real world you don't deal with Some and None much -- pretty quickly it's all Option anyway.

emmanueltouzery commented 6 years ago

Hmm that's a change I authored on a feature branch of mine. I assume you didn't actually intend to open a PR. Reopen if i'm mistaken.