Updated February 18, 2023
Introduction to TypeScript Handbook
The typescript handbook has been planned to be a complete document that demonstrates typescript to everyday programmers. We can interpret the handbook by proceeding from the top to the bottom in the left-hand side navigation, and we can look forward to each chapter or page by giving a strong grasp of the provided concept. The objective of the typescript handbook is to be a static type-checker for JavaScript programs as it is not absolute language defining but it is considered as a guide to all languages features, it can run previous to the implementation of the code.
The typescript handbook is not totally created for language description, but it can also be utilized as a guide to all the language features and bearing in which a reader can able to look through and also can able to recognize frequently used syntax and design. The handbook is also planned to be a substitution for the language defining, in some of the conditions the bearing of it can be skipped in commendation of the high-level, uncomplicated to understand. Instead of that, it has different reference pages which are more accurately able to describe. The reference pages of it cannot able to deliberate for readers which are not familiar with typescript so they can utilize the up-to-date terminologies that have not been scrutinized so far.
How is TypeScript Handbook Structured?
The structure of the typescript handbook is divided into two parts:
1. The Handbook
The purpose of the TypeScript handbook is to demonstrate the typescript to the developers every day and the handbook is in the form of a document, in which developers can scrutinize the handbook by going from top to bottom which is available on the left-hand navigation. We can look forward to every chapter or page that can give us a powerful comprehension of the provided hypothesis; it is not an accomplished language definition but it is deliberated to be a general guide to all language attributes and etiquette.
The reader who finished the exercise that should be able to:
- Understand and study frequently utilized syntax and design of the typescript.
- Demonstrate the outcome of major compiler options.
- Forecast the attitude of the type system in most instances.
In profit of transparency and verbosity, the main content of the handbook will not inspect each border of the features that are being counterbalanced, we can also search out the additional set out on the special concept.
2. Reference Files
This component of the handbook in the navigation is constructed to give a plentiful comprehension of how the specific section of the typescript can slog, in which we can able to scrutinize it from top to the bottom but every portion focus to give an intense simplification of a single concept which means there is no focus on flow.
Basic Types of TypeScript Handbook
Given below are the basic types of TypeScript Handbook:
1. Union Type
Two types can be merged by using ‘union type’, which can also be created from two or more other types. It can act for values that may be one of those types. Let us see the function which can be utilized on strings or numbers.
Code:
function printId(id: number | string) {
console.log("This is your id: " + id);
}
printId(1001);
printId("2001");
printId({yourID: 333441});
Argument of type '{yourID: number;}' is not conveyable to the argument type 'string | number'.
Output:
2. Object Type
In JavaScript basically, the data can proceed through objects but in TypeScript, that data can be constituted by object types.
Code:
function greet (human: {name: string; age: number})
{
return "Hi" + human.name;
}
In this example the function which can be used holds objects having the property ‘name’ which is the string, and the age which is the ‘number’.
3. Erased Type
Let us take a glance at what comes when we try to compile the ‘greet’ function with ‘tsc’ to yield the JavaScript.
Code:
"use strict";
function greet(human, date) {
console.log("Hi".concat(human, ", today is ").concat(date.toDateS
}
greet ("Clove", new Date ());
4. Explicit Type
Let’s use one example to illustrate what the explicit type is.
Code:
function greet (human: string, date: Date)
{
console.log ("Hi, ${human}, today is ${date.toDateString()}")
}
We have not informed the typescript what ‘human’ or ‘date’ are so we have corrected the code to inform that the typescript that ‘human’ is ‘string’ and ‘date’ should be the ‘Date’ object and we have utilized ‘toDateString()’ method on ‘date’.
TypeScript Handbook Help to Engineers
- Educating JavaScript to the Experts: JavaScript can be learned from a variety of resources, including books, as there is no need to take part in it. The primary goal of the handbook is to assist engineers in understanding the process of TypeScript construction on JavaScript so that such a focus on our documentation can create assumptions about the background and avoid describing JavaScript features from the ground up. This is not to say that we do not want to respect people based on various skill levels with the help of a handbook.
- Educate Gradually: We need to construct concepts on top of everyone in a straight way to keep away from the typescript features which are not described, such restriction can perform a very nice task of compelling us to re-think the order and classify the language concept.
- Interpret the Everyday Cases: Around 8 years the typescript has not removed any feature which is documenting all the feasible utilization and workable options for any concept which has been passed out of their authority of the handbook and into also through our growing portion of reference pages.
Conclusion
In this article, we conclude that the typescript handbook can help the programmers to plan the total document which can signify the typescript. We have also discussed how the typescript handbook has been structured, the basic types of typescript handbook, and also how the typescript handbook helps the engineers with an introduction.
Recommended Articles
This is a guide to TypeScript Handbook. Here we discuss the introduction, how is the TypeScript handbook structured? and types. You may also have a look at the following articles to learn more –