Skip to content

another good example/test #49

@getify

Description

@getify
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:

Metadata

Metadata

Assignees

Labels

cool-exampleSomething very interesting to look at

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions