Welcome to Typescript interview questions (pdf) and answers for beginners, Here are some tricky typescript interview question and answers collection which is asked in the interview. May it will help you to crack your typescript interview.
1. What is namespace in Typescript? Write the declaration of the namespace.
I think Everyone familiar with the namespace of other languages, here also in TypeScript a namespace is just a collection of classes by which we can logically categories. If we want to access any class from outside of the namespace then we need to export keyword.
export class Boss
export class Employee
export interface Iofficework
2. What is Typescript?
4. What are the key features of typescript?
5.When to use a super keyword in typescript.
In typescript, Super keyword is used to reference base class properties and the base class constructor.
6.How to access static methods in TypeScript
7. What Are Classes In Typescript?
The concept of classes is very similar to .NET/Java. A Class can have constructor, member variables, properties, and methods. TypeScript also allows access to modifiers “private” and “public” for member variables and functions.
8. Tell me the command for installing typescript.
npm install -g typescript
9. What Are The Benefits Of Typescript?
TypeScript has the following benefits:
2Impose coding guidelines
3.Offers type checking
4. It helps in code structuring
5.Compile time error checking
6. Use class-based object-oriented programming
10. What is the typescript extension and how you compile?
Step to compile a typescript program
1. tsc 'your typeScript File Name'
For example, to compile “program.ts”:
After compilation, you will get
11. How to declare a variable in Typescript?
12. How do you declare an undefined variable?
13. How to declare and initialize an array in Typescript?
var names:string; -- Declaration
names=["a","b","c","d"] -- Initialization
14. How to achieve inheritance in Typescript?
15. How to make a module in Typescript?
16. What is the role of constructor in Typescript?
A constructor is responsible for initializing the variable of the class.
17. How to initialize the static variables?
18. What is the difference between var and let in Typescript?
1.var declaration done at function scoped and let declaration done at block scoped.
2.var allow you to re-declare the same variable in the same scope. whereas let will not
19.How to define a global variable in a typescript module.
20.How to export a variable.
export var demo = [1,2,3];
21. What is the role of var keyword in typescript?
var is key it helps us to create an object of a class.
22. How to Convert string to number in TypeScript?
//convert string to number
this.empcode = Number(name);
23. Can we debug Typescript file?
Yes, With the help of .js source map file.
24. What are the classes in TypeScript?
Typescript class is very similar to other languages like (.Net, Java). As we know that class can have constructor, member, variable and methods.
25. What are the benefits of Typescript?
1. ES7 and ES6 Features support.
2. User-friendly for Java and .Net programmer.
4. Object Oriented programming support.
TAG: Typescript interview questions and answers for beginners, Typescript interview question and answers, beginner typescript question and answer