TypeScript Mock Interview | Interview Questions for TypeScript Developers

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
foreign [Music] we are back with another round of 2D Mark interview series I'm Jose Attack lead at Turing and I'm from Montreal Canada and today I'll be interviewing romulo for the role of an experienced typescript developer okay and before you put in the comments get the question are easy or hard these questions were selected for YouTube purpose okay if you come to Twitter interview you might get different question in your interview alright so without further Ado uh let's get start this interview uh first of all Hi romulu how are you doing and how is your day doing so far hey she's uh yeah uh thanks for having me uh I'm doing great great how are you uh nice I'm doing great as well I'm preparing for the winter the winter is coming in snowboard season it's almost up and I'll be there for sure and thank you for asking by the way so uh let's let's hear a little bit from you romulo could you please uh introduce yourself and tell me a little bit about your background okay your professional experience then I'll take from there sure uh so I am a software engineer currently based in Brazil um and I have around six years of experience with front-end development specifically and I have worked mostly for focused on react applications I would say um yeah that's pretty much it on my experience nice all right could you please tell me a little bit uh about some interesting projects that you have been work uh with typescript sure uh I have worked on quite a few different interesting projects uh such as e-commerce websites for retail companies in the US and in Brazil as well I have done some work on online business platforms and most recently I am working on a no code low code tools for API Engineers all right okay so my first question uh what is typescript okay so typescript is basically a programming language right so it's a programming language that was developed by Microsoft that adds some nice features on top of JavaScript such as new syntax and and types uh yeah that's basically it in a short sentence nice nice and what is your I mean uh what is what you have in mind about typescript do you like typescript or you you hate typescript because I have I have seen this so far okay people that like and hate typescript which one are you there was a time long ago that I used to hate it I have to be honest but today I just love it because well JavaScript is not strongly typed right so it's kind of difficult sometimes to get like to figure out what what types of data uh are being passed around in your code and that can lead to all sorts of ones right so that's one of the cases in which typescript comes in Hindi so it's mostly a matter of add adding more quality to your code and shooting less bugs into production and uh also developing with more speed I would say so yeah I love it nice and a big fan typescript as well okay so all right so now let's talk about typescript okay um in your understanding uh what are the different components in typescript Okay so the different components are so first I would say the language itself because I think it's like the most important support the developer's face when they encounter typescript right because we have new scene tags new keywords that allow us to write types in typescript okay so this is the first so second I would say the compiler because well browsers and some JavaScript engines they don't really understand typescript right so for us to be able to actually write in typescript and run that on the internet we need compilers to get all the typescript code and transpile this and and compile it to JavaScript so that browsers and other engines can understand um and last but not least uh and this is one of my favorites like the language service behind typescript uh and and this language server usually comes uh embedded in some um code editors like the vs code um and visual code Studio as well so is this very powerful service that keeps um like past like parsing your typescript code and um show you some other competitions show you some errors uh during development time so yeah so I think this is the last in in a very cool component as well of the language nice nice so um why should we use typescript in your understanding um first of all I would say that we should use it because it really adds more quality to your code because there's tons of very small bugs that we can ship into production just by not having a restricted type language right so this is one and uh second I would say again because of the typescript language service it's really magical sometimes to to to writing typescript because it feels like your IDE it fully understands what you're doing so it so it keeps reading from all different files trying to understand what you're trying to write so it gives very nice Auto competition and make sure that you're not messing things around uh while you are writing in typescript when compared to JavaScript well there is a bit of a learning curve in the beginning which is uh which is uh okay but another thing is is that you can write typescript together with JavaScript so while you are learning typescript you can actually learn it progressively right you don't need to get all of your application and turn it into typescript at once you can do it slowly so so that's very nice nice all right okay thank you for sharing so um next question for you is what are the access modifiers supported by typescript okay so the access modifiers are three so we have the public which is the default so every time you define a class parameter or a method it's public by default which means that all other classes and parts of your code can access this method or this property so the second access modifier is the private which means that only the class that holds that parameter or the method can access it and third is the protected access modifier so it's it works quite similarly to the private one but uh when you have a protected method for example the class itself can access it and also all the subclasses can access it as well so if you have a class that inherit from another class that can use your protected methods as well but that's not available to be outside okay so those are okay so what type did typescript add to JavaScript so um we have of course all the Primitive types that JavaScript has right which are um string numbers Boolean uh objects and uh and so on so all the types that are already in JavaScript are in typescript as well but typescript has some new exclusive types I would say which are tuples and and also types that you can Define within your code so you can Define types that are made out of other primitive types and they also have interfaces as well that can be used as a type kind of thing but they work a little bit differently so yeah but nice then I have two follow-up questions for you okay so you mentioned types animation interface okay uh and you have you mentioned also primitive types so I'm going to ask you about genetic types uh button before that I would like to ask you what are the difference between um let's say interface and a type and when should we use the interface and when should we use a type okay so typescript types are basically types that you create for for your variables or your objects and they are more strict in a way that I cannot extend them I cannot uh use them together with other types so so yeah that's pretty much what type and typescript is all about and we but we also have interfaces which is a way that you can Define the type of your data right right so I can say that I have a object that is of interface I don't know car uh but that interface can be extended as well so I can create another interface or or a class that extends an interface and I can also use some operations with interfaces as well like adding interfaces together and that sort of thing so that's basically the the difference nice but now we can extend from types as well okay oh yeah yeah we can do that but okay my next question is regarding types okay uh what are generic types in typescript uh so generics and typescript are basically ways that you can pass types as variables to other types uh so for example let's say that I'm creating a fetching function right so fetching functions usually they return promises but uh that doesn't really tell me what type of data is coming from that promise so that's a very useful uh case for for generic types and typescript for so I can create a function that returns a promise and that returning type can have a generic type as a variable so I can say for example that I'm calling this hatching function and Dot patching function will get me will return me a promise of a list of names for example so that's the usage example of generic types in times groups okay and what what do you understand about uh structure typing in typescript um instructional typing is uh is it kind of a concept that means that while you are comparing types in the language the way that it Compares it is that it only uh assess the members of that type so let's say that I have a type called car in another type called vehicle and those two types have one I have only one um parameter member which is the let's say the number of wheels of type number so if I have a variable of type car in another variable of type vehicle I can interchangeably assign one to another and that's fine because even though they are of different types the structure of that object is the same so they can be assigned to each other some other languages don't allow you to do that so that's basically what structured typing is all about nice all right so uh next question is uh related to private Fields okay uh could you please uh let me know a few rules of the private fields in typescript [Music] okay so private Fields um are fields that are uniquely scoped in the containing class so different from protected uh methods or private methods uh private Fields cannot uh in any case be accessed from the outside and and cannot be accessed as well from like sub classes and uh and private fields are very particular to typescript as well because the way that the compiler compiles your account using private Fields um makes it unaccessible even by Time by by JavaScript so it's like a all hidden thing in your typescript class okay and this one is tricky okay so uh how to choose between uh never I know and any in-type script okay um that one is Trick indeed uh well first of all the never type is when you want to um objectively say that a variable will never have a type and should never have a type so that's when you use never uh and then we have unknown in any they kind of behave similarly so but the key difference there is that um any doesn't do any type checking basically so let's say that I have a variable of type any I can I can ask I can assign every data to that variable that I'll I'll not get a an error uh while if you use the unknown type it means that variable has some sort of type so let's say it's uh either a string or unknown um so if you try to assign something different it will give you an error so that's basically it all right but I am a bit confused okay um so any we can assign any type there right and for example if you assign an integer to any and then try to assign a object or I String is that possible oh well change the type I mean oh yeah so if you change the type I I don't think it's possible I'm not sure there but I would say that it's not possible because while because after you do the first assignment JavaScript understands that that variable of that type and then it will not let you assign something different I would say I'm not 100 sure but okay but all right uh then I will ask you the same question for never okay if I declare a variable and say this it's the type is never okay if if I assign an integer can I assign a string um I mean after I would say no duh you would have an error okay I will ask this question for our audience okay do you agree because when you come to a tour interview uh I expect okay uh I don't expect you to know every question okay every answer and that's okay if you don't know okay it makes sense because uh sometimes you are most familiar with uh this this but not with that and totally fine okay if you don't answer all the questions cool all right so next question uh could you please explain when to use uh declare keyword in typescript okay uh so typescript has this special keyword declared that is useful in some cases for um when typescript itself doesn't know the type of a certain method or variable or the library you're importing from doesn't have types so let's say that I'm calling a uh a some function file for my for my library but that Library doesn't have types so typescript doesn't have any way to figure out what's the uh parameters types that that function receives or the type of the returning object so we can basically use this declare keyword to declare the types for that Library so that typescript will not like screen errors at you so so that's basically the usage basically it will let you pass right and then you queued my next question because I would have a follow-up question that would be if it's possible to generate types declarations from a JS Library lab but you mentioned yeah you can declare that right before what are ambience in typescript and when should we use them I think I'll have to let that one to the audience and stop because I never worked with that and I have no idea okay all right that will ask to this question for our audience as well okay so uh if you are watching this video and you are familiar with typescript okay what are ambience in typescript and when should we use them please let me know in the comment section below okay and as that said that was my last question okay I would like thank you romulo that was an interesting conversation with you and I hope to see you again in the future okay sure thank you thank you for having me again it was really nice talking to you and talking about the typescript yeah and I hope you guys enjoy it all right so as that said that's a Rob from our side okay if you uh have any query okay you can uh email us at support tutin.com okay and they will try to reply your message at least at the same day okay uh give us a big fat thumbs up right now okay just pressing the this thumbs up below uh it's free okay if you are not subscribed to our Channel go ahead click in the red button below it's free it's easy and it's uh quickly so if you want to find jobs and work remotely for us companies go to touring.com it's less jobs and apply for the job that are suitable for your tax Tech if you don't have account I really encourage you to create account it's also free easy and quickly okay as that said that's a wrap thank you for watching keep tuning for the next uh touring video and let me know in the comment section below what you think about this and what like what kind of videos you would like to see in the upcoming video till then stay safe keep learning and I hope to see you all again take care [Music]
Info
Channel: Turing
Views: 33,293
Rating: undefined out of 5
Keywords: TypeScript, TypeScript Developers, TypeScript Questions, Interview Questions, Technical Interview, TypeScript Interview, TypeScript Remote Jobs, TypeScript Jobs, TypeScript Devs, Remote Developer Jobs, Turing Jobs, Turing Remote Jobs, Turing Remote Developers
Id: CqzsdfxYnm0
Channel Id: undefined
Length: 20min 58sec (1258 seconds)
Published: Thu Nov 17 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.