A builder that takes overrides

Test data types must describe the objects the helpers actually create.

your task

Let buildBooking accept any subset of fields, including none. Supplied values must replace defaults. Exclude id from the create request and its type. Use utility types based on Booking. The marked access must be rejected and all cases must pass.

A test supplies new field values, called overrides. The builder ignores them. The create request also contains an id, although the service assigns that field.

Starter code
or press Ctrl EnterNot run yet

type check

Not run yetbuilder.ts

Expected result: no type errors.

cases

Not run yetDefault booking

Expected output

1{"id":1,"room":"Atlas","seats":4,"paid":false}
See the input and the code for this case
console.log(buildBooking());
Not run yetNew seats and payment status

Expected output

1{"id":1,"room":"Atlas","seats":8,"paid":true}
See the input and the code for this case
console.log(buildBooking({ seats: 8, paid: true }));
Not run yetCreate request without an id

Expected output

1{"room":"Birch","seats":4,"paid":false}
See the input and the code for this case
console.log(createPayload(buildBooking({ room: "Birch" })));