Globals 4 exercises
Problem

TypeScript's Global Scope

In this exercise we're going to be typing things in the global scope.

Here we have a globalThis that is being assigned to myFunc, which is a function that just returns a boolean. We're also assigning it myVar as 1:


globalThis.myFunc = () => true;
globalThis.myVar = 1;

In

Loading exercise

Transcript

0:00 In this exercise, we're going to be typing things in the global scope. Here we have a globalThis which we're assigning myFunc to. This myFunc is going to be a function that just returns a Boolean there.

0:13 We're also assigning myVar as a one here and we're expecting this to be type of number. We've got expect myFunc to be 1, so we're expecting to be able to call this, but it says cannot find name myFunc and down here cannot find name myVar either.

0:29 We need to find some way with TypeScript to put this in the global scope so we can test it out. I have given you a bit of a ramp on here. We've got some syntax here that you can google, we've got some stuff here that you can look at, and we've got some stuff here you can use.

0:43 That's because this stuff is actually really hard to find in the TypeScript docs and this should give you a little bit of a sense of what's going on there. We've got here type of myFunc is expected to be this type and type of myVar is expected to be this type.

0:58 I think that's all the info I'm going to give you. Good luck.