Now, we've completed our initial implementation of our user.
We can try to actually make use of it inside of our index sites file in general any time we create a
file that houses a single class in typescript.
We're not going to have any actual code in here that does anything with the class.
Instead, we will usually import this class into some other more central location and use it from there.
So in order to get access to this class inside of our indexed Ortez file, we first have to export it.
So to make the class available somewhere else inside of our project, I'm going to put the export keyword
in front of it like so.
Then inside of index starts at the very top of the file, I'm going to delete that console log really
quick.
We can write out to import a set of curly braces and then user from the user file.
Now, if you're coming from a background of reactivates, chances are the syntax looks really familiar.
Once again, we are going to look into the user file.
We're going to find something inside there called user and pull it into the index file as a variable
called user.
Notice how we've got the curly braces on here, won't have a very quick aside on what those curly braces
are doing for us.
So any time that we export something from a file using just the export keyword by itself, we will always
receive that in another file by placing that word inside of a set of curly braces.
We do this so that we can safely export multiple different variables from this file.
So, for example, if we had another variable inside of here that we wanted to export, like, let's
say a variable called red, that was literally just a string red.
I can now import this into index notes by adding it as an additional thing that we want to import from
user.
Once again, if you're coming from the world of react, the syntax might seem a little bit strange because
in the react world we typically will export things using the default keyword.
The default keyword is available inside of TypeScript as well.
If you haven't used the default keyword, totally fine.
Let's take a look at how it works really quickly.
So right now, we've seen an example of how we can export very specific variables from a given file.
However, we can choose to also export something as the default export from a file as well.
So I could say export default and then just a single value by itself.
So in this case, I did not provide a name for this value.
I'm trying to export.
Previously I had given it a name of red, which means I could import it into another file as the name
Red.
But this time it's literally just the string red by itself.
So to import this value into another file, I would write out no curly braces and just the name of the
thing I want to pull in.
It's now red would be that string red.
This name right here can actually be any variable we want to call it.
So I could call it red or I could call it color or user color or whatever we want it to be.
If we then did a console log of that.
We would see literally just a strong red, that's it.
In typescript, we usually do not use these default statements like the one you see right here.
The reason for that is that when you're first getting started with these modules, like this import
statement and this expert statement right here, it gets really confusing really quickly when you should
use curly braces and when you shouldn't.
So convention inside of TypeScript is to never use default export statements.
Now, of course, there will be some people out there who disagree and who want to still use default
default statements.
If you work on a project where that is the case and you want to use default statements, totally fine.
All I'm saying is that in the typescript world, it's a little bit more community convention to not
use default exports.
And once again, the reason for that is that then we don't have to worry about whether or not we have
to include those curly braces.
So if I don't have any default exports whatsoever, that means every time I import any code that is
mine, I'm always going to put on those curly braces.
So it just makes it really easy for me to remember and avoids simple little typos.
Now, of course, that rule does not apply to third party modules, so new modules we use might still
have a default expert statement, as is the case with Fakher right here.
And that's totally fine.
It is unavoidable.
Nonetheless, the rule for us for code that we write is that we will avoid default statements if we
can.
OK, so that's a lot on default exports and all that kind of good stuff.
So last thing, now that we've got the user inside of our index file, let's try to use it to create
a new instance of a user.
And then just log out that user.
All right, now that I've got that, I'll flip back over to my terminal, I've already got a live reload
here and you'll see that I've got a console log of my users.
They have a name and a location that is an object with the latitude and longitude property as well.
Perfect.
All right.
So now we've got our user all put together and we can access them inside of our index file.
We're not going to repeat this whole same process for a company as well.
It's a quick pause and I'll see you in just a minute.