TypL icon indicating copy to clipboard operation
TypL copied to clipboard

another good example/test

Open getify opened this issue 3 years ago • 0 comments

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:

  1. Trigger an error on the add('a') call since that string value doesn't match the number type that was implied by the previous add(1) call. Ditto for the ('b') call. These errors could be configured off if you didn't want them.
  2. Expand the implied type for the x function parameter to be a union type (number | string), as well as y, so future calls can send either type for either parameter.
  3. Trigger an error on the + operation when the 1 and 'b' are added. Again, this error could be configured off.
  4. a - 1 would definitely be allowed, since a was implied as a number.

Other results:

getify avatar May 27 '21 12:05 getify