1
00:00:00,930 --> 00:00:05,040
In the last video, he spoke about why the new type is a very bad thing to have inside of application

2
00:00:05,550 --> 00:00:11,460
right now, coordinates is of type any and it's only the case because Jason Persse returns a value of

3
00:00:11,460 --> 00:00:12,050
type any.

4
00:00:12,090 --> 00:00:16,560
And that's because TypeScript just can't predict what Jason is going to return.

5
00:00:17,220 --> 00:00:22,410
So to fix this up, one way we could fix it is to add in a type annotation for coordinates.

6
00:00:23,510 --> 00:00:29,510
So we need to add in a type invitation for an object, we already saw an example of that right back

7
00:00:29,510 --> 00:00:32,290
up here when we define the object, literal of point.

8
00:00:33,080 --> 00:00:38,510
So to add in a type annotation for an object right after the variable name were put in that colon and

9
00:00:38,510 --> 00:00:40,970
then the overall structure of that object.

10
00:00:41,940 --> 00:00:46,770
So for us, we're going to add in coordinates right here, I'll put in a colon then instead of curly

11
00:00:46,770 --> 00:00:51,720
braces and inside they're going to say this thing is going to have a property called X that is a number

12
00:00:52,200 --> 00:00:55,160
and it's going to have a property Y that is a number as well.

13
00:00:56,650 --> 00:01:01,510
So now we've given enough information to TypeScript that it can figure out what type of value coordinates

14
00:01:01,510 --> 00:01:07,840
is by now mouseover it, I see the type annotation on here and now if I try to reference, say, coordinates,

15
00:01:07,840 --> 00:01:12,820
dot, blah, blah, blah, I'll very quickly see an error message that tells me that is not a property

16
00:01:12,850 --> 00:01:13,810
on that object.

17
00:01:14,790 --> 00:01:15,880
OK, so that's pretty much it.

18
00:01:16,110 --> 00:01:21,300
This is one of the three cases where we are going to add in type annotations anytime we call a function

19
00:01:21,330 --> 00:01:27,200
that returns type any adjacent parts is just one of the functions in JavaScript that returns type any.

20
00:01:27,210 --> 00:01:28,710
There are several others as well.

21
00:01:29,070 --> 00:01:31,710
So we'll kind of see some of those different functions over time.

22
00:01:31,920 --> 00:01:35,910
And in fact, we might eventually have to write our own functions that return type any as well.

23
00:01:36,900 --> 00:01:38,430
All right, let's take a quick pause right here.

24
00:01:38,430 --> 00:01:43,080
When we come back in the next video, we'll move on to the next example or the next case where we are

25
00:01:43,080 --> 00:01:46,200
going to add in a type invitation willingly.

26
00:01:46,470 --> 00:01:48,480
So quick pause and I'll see you in just a minute.

