TypeScript Essentials: Functions & Objects | Compiling Interface Code

TypeScript
Transcript

English (Auto-generated)

in the interface and how we can intersect the interface. So first of all let's just create a simple interface and I'm going to create one interface actually I have created one earlier in the previous cast but I've deleted that and I'm creating it again because um I want you know practice makes things better. So I want you to practice it again. So you know, just like that. So anyway in the interfaces person again person Okay and sorry. Okay now the name should be string and uh the name should be strengthening. The height should be number, the age should be number and uh It should be number for now. Just just take to these. Okay. And I'm writing person one. Sorry let person one and uh person I'm assigning this interface to to hear and equal to Ok. Now for now this is empty because it's following this interface. So it literally tells that this is missing the following properties from the type person name hide and age your name hide and age so we need them. Okay so first of all I'm writing the name and in the name I'm writing I can write anything though. Now the next is high. It G H T Hyatt and here I am writing like you know 28 then the age the age is just a number. The age is just a number of these 28. The height is 5.9. Now that is actually suits okay I think before moving to the intersection and the extending and talking about that. Let's just try to see how it looks in the Js. This is the old thing, I'm deleting that believing is not necessary because when we do the the compiling it would it would automatically lead the previously stuff and update with the new one. Anyway, I'm going there and I'm writing TSC just reminding you because we have created the conflict file for the T. S. So we can write TSC but in your case you have, if you if you didn't didn't create the TSC convict file um and we created it using the command line just telling you. So it has a lot of stuff you can see that if you just don't have this file or you didn't generate this file by initiating the typescript configuration you have to mention the TSC and then the file name which is index or it can be anything. Okay, so I'm writing TSC and I'm pressing the enter key and I'm gonna have okay, it is updated, I can go there now. Um it looks like a simple object. The interface is not there, the interfaces here but it is not here. Why because this is um this is a simple object and this one and javascript doesn't support the interface. It is the feature of the typescript originally. So the typescript, you know one more thing. One more interesting thing because the typescript was actually created by Microsoft in their own labs for their own employees earlier. So the interface and things like that are actually the features of the um these are not the feature of um uh the the the general, you know, the Js but these are the options, these are the features of C. Sharp and things like that. So these are actually, you know the the you know designed by Microsoft originally and Microsoft implemented them in the T. S. So anyway you can see that here because javascript doesn't support them to javascript is in the simple javascript form. It is t it is the job of the typescript to define you to, you know, to restrict you if there is any problem, there is any issue with the codes for example, you try to make it B. B. You know uh the string then it tells you that, you know, according to the interface, you have to you have to follow something different. So it is the job of the typescript, not the javascript. So the typescript is telling you by putting the red line and you need to work on it and then you can convert or compile it. Anyway. Now we're gonna go to the next step and I think uh um I think we just had enough discussion about the about the J. S. And the T. S. In this video. So I think we should move to the next video and then we can talk something else. Actually we're gonna talk about extending and the interest section in the next video and we are I'm not going to believe this content. We're gonna use that again until then stay tuned.
131 Views 0 Likes 0 Comments

We go over the concept of compiling interface code in JavaScript.

Comment
Leave a comment (supports markdown format)