Integrated Development Environments Superpowers 13 exercises
Problem

Fast Imports in VS Code

It's common to need to import several variables from a separate module.

For example, let's say we have a file called dummy-import.ts that exports a bunch of variables:


// inside dummy-import.ts
export const SESSION_EXPIRATION_TIME = 1000 * 60 * 60 * 24 * 7; // 7 days
export const SESSIO

Loading exercise

Transcript

00:00 Here we've got a setup for a very common problem in TypeScript. Let's say that we've taken this piece of code from a different file and we've put it in its own module. Now what we need to do is we need to reference all of these things here that no longer have references.

00:18 So we need to import them over. But there's a bunch here. So we've got session expiration time, session expiration time in seconds, in minutes, and in hours. And these are all coming from this file down here, dummy import. So they're all exported. They're ready to go. We just need to import them. And we need to do it as fast as possible.

00:36 So time yourself. Make sure that you're ready to go, that you're hydrated. I want you to see if you can find a way to import these variables as fast as possible. There are two possible solutions. Well, three possible solutions, although one is very, very slow. Good luck.