danielnixon / eslint-plugin-total-functions

An ESLint plugin to enforce the use of total functions (and prevent the use of partial functions) in TypeScript.
MIT License
88 stars 4 forks source link

New rule: prevent unsafe assignment of fp-ts types #728

Open danielnixon opened 1 year ago

danielnixon commented 1 year ago
export const foo: IO<string> = () => "hello";

// These assignments compile because the types are compatible, but the semantics are such that doing so is almost certainly an error.
export const bar: Lazy<string> = foo;
export const baz: () => string = foo;
danielnixon commented 1 year ago

We should also catch when a Promise is being assigned to an IO like IO.of(Axios.get(...)), or any async effect being assigned to an IO for that matter.

danielnixon commented 1 year ago

That latter point is covered by total-functions/no-nested-fp-ts-effects