Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

web development
typescript
javascript

What is TypeScript?

Educative Answers Team

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

TypeScript is JavaScript which is designed to scale web applications.

As an object-based scripting language, JavaScript is designed by Netscape in 1995. It has an open standard (ECMAScript) and a huge developer community.

TypeScript is an object-oriented language designed by Microsoft in 2012. It is a superset of JavaScript and can be used both a language and a set of tools. It provides optional static typing, which can help to catch errors as they appear making it ideal for large team collaborations.

svg viewer

Advantages

  • TypeScript can point out compilation errors at the time of development.

  • It, as mentioned above, offers static typing which allows catching type errors at compile time and therefore gives a less painful development experience.

  • It is great for large team collaborations.

svg viewer
  • Perhaps the biggest feature that TypeScript provides is type-checking, which can prevent bugs such as the one below:
// TypeScript
function fetchUserID(isUser: boolean) : string {
if (isUser) {
return '94321';
}
return 'username not present';
}
// throws: error TS2345: Argument of type '"true"'
// is not assignable to parameter of type 'boolean'.
let userId = fetchUserID('true');

In the above code, we are passing a string to fetchUserID() function which is expecting a boolean variable. So, it will throw an exception:

Argument of type true is not assignable to the parameter of type boolean.

Sections of TypeScript

TypeScript has the following three sections:

Language: It is an object-oriented language which can be broadly divided into three things:

  • Syntax
  • Keywords
  • Type Annotations

TypeScript compiler: Translates the instructions written in TypeScript to JavaScript.

TypeScript language service: Supports editor operations such as:

  • Statement completion
  • Code formatting
  • Colorization
svg viewer

RELATED TAGS

web development
typescript
javascript
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring