Inference Basics 6 exercises
Problem

Create a Union Type From an Object’s Keys

Consider this object, which contains several testing frameworks as keys:


const testingFrameworks
vitest: {
label: "Vitest",
},
jest: {
label: "Jest",
},
mocha: {
label: "Mocha",
},
};
type TestingFramework = unknown;

Challenge

The vitest, jest, and mocha

Loading exercise

Transcript

0:00 In this exercise, we have a bunch of testing frameworks here. We want to extract a union type of each of these keys. We want to get Vitest, Jest, and Mocker into a union. What that's going to look like is we could do this with Vitest or Jest, or Mocker here.

0:20 That's going to satisfy our test. Ideally, we want to extract this from the object here. That's your job. We're going to need typeof again. We're also going to need a new bit of syntax that we've never seen before. Good luck.