We examine the basic types in TypeScript, and examine how variables are assigned a type, including type inference and explicit setting of the type.
- [Instrutor] Let's take a look at the boolean type,…which is, very very similar, as you might expect,…to the bool type in C#.…We'll create a new file, and we'll call it…booleanDemo.ts…Got to remember that .ts extension…to make it a TypeScript file.…And we're going to say function…booleanDemo.…And our booleanDemo is going to take one parameter,…of type boolean.…isOld is the name of the parameter, and the type is Boolean.…
And notice that the type is capitalized…and spelled out, Boolean.…All right, with that in place,…we have a boolean value isOld.…We can test it, if (isOld)…which is exactly the same as if (isOld == true)…So if (isOld)…Then we're going to write to the console,…"You are old"…And then, let's put in an else.…And we'll say that if isOld is false,…we're going to write to the console…"You are not old"…All right, we now have a complete function.…
We can call it,…and pass in either true or false.…Let's pass in true.…Build.…Go over to our terminal.…Say $node booleanDemo…And sure enough, it comes up and says "You are old"…
In this course, Jesse Liberty reviews the fundamentals of TypeScript for the C# developer, including the built-in types, flow controls, and functions. He covers default, optional, and rest parameters; lambda functions; object literals; and the creation and use of custom classes. Plus, learn about other object-oriented features such as inheritance and interfaces. By the end of the course, C# developers should be well on their way to incorporating this flexible and powerful web programming language into their app development workflow.
- Setting up a TypeScript development environment
- Working with types and variables
- Using operators to control flow
- Working with parameters and functions
- Creating classes and objects
- Exploring TypeScript inheritance
- Working with interfaces