TypL
TypL copied to clipboard
another good example/test
const add = x => y => x + y;
const a = add(1)(2);
const b = add('a')('b');
const c = add(1)('b');
a - 1;
Expected results:
- Trigger an error on the
add('a')
call since that string value doesn't match thenumber
type that was implied by the previousadd(1)
call. Ditto for the('b')
call. These errors could be configured off if you didn't want them. - Expand the implied type for the
x
function parameter to be a union type (number | string
), as well asy
, so future calls can send either type for either parameter. - Trigger an error on the
+
operation when the1
and'b'
are added. Again, this error could be configured off. -
a - 1
would definitely be allowed, sincea
was implied as anumber
.
Other results: