Category: Typescript

Working with Interfaces in Typescript

In our last article, we discussed how to work with Enums, functions and anonymous functions. In this article, we will discuss about Interfaces in Typescript.

Interface

One of TypeScript’s core principles is that type-checking focuses on the shape that values have. This is sometimes called “duck typing” or “structural subtyping”. In TypeScript, interfaces fill the role of naming these types, and are a powerful way of defining contracts within your code as well as contracts with code outside of your project.

Type interference to actual types

Now our existing function we discussed in previous post will become from this

Read more

Angular 2 automation with Protractor + Typescript + Cucumber

Dear friends,

I am very happy to release the next big course in Udemy on Angular 2 automation with Protractor + Typescript + Cucumber.

This course is very interesting and one of my long time goal/ambition to release for QA community, since I find Zero or No resource on Protractor automation testing at least with Typescript combination.

The course features following topics

  • Understand building Angular 2 application with Angular-cli
  • Understanding and working with Jasmine
  • Understanding and working with Protractor (Basic)
  • Understanding and working with Protractor (Advanced)
  • Working with Cucumber and Protractor with Typescript

The course has not only covered very basic topics on Protractor, but it has also covered some of the advanced concepts which are required for production ready and industry standard.

Here is the complete introduction video of the above discussion

Thanks for reading the post and watching the video!!!

Please leave your comments and let me know if there is anything I should update in this post.

Thanks,
Karthik KK

Working with Functions, Anonymous and Arrow functions in Typescript

In our last post we discussed how to work with Variable, Enums and Arrays in Typescript. In this post we will discuss working with different types of functions

Functions

Functions are the fundamental building block of any applications in JavaScript. They’re how you build up layers of abstraction, mimicking classes, information hiding, and modules. In TypeScript, while there are classes, namespaces, and modules, functions still play the key role in describing how to do things. TypeScript also adds some new capabilities to the standard JavaScript functions to make them easier to work with

Function Parameters

  1. Parameter with types
  2. Rest parameters
  3. Default parameters

Parameters with Types

This function looks something like this

Rest Parameters

Default Parameters

Anonymous Functions

Functions which don’t have Name/identifiers are considered as Anonymous functions. These functions are dynamic and called during runtime

Arrow Functions

Read more

Working with Variables, Enums and Arrays with Typescript

In our last post we discussed an introduction and installation of Typescript, in this post we will discuss how to work with Variables, Enums and Arrays with Typescript.

Working with Variables

There are different types available in Typescript which are almost available in JS like

  1. Number
  2. String
  3. Boolean
  4. Any
  5. void
  6. Null

Variable Declaration

Declarations of variable can be done with following in Typescript

  1. let
  2. const
  3. var

Working with Arrays and Enums

Enums allow us to define a set of named numeric constants. An enum can be defined using the enum keyword.

Arrays

Inserting an value in to an array can be done something like this

Here is the complete source code of the above discussion in GitHub

Read more

Introduction and Installation of Typescript

In this post we will discuss an Introduction and Installation of Typescript

Typescript

Typescript is the typed superset of Javascript that compiles(transpiles) to Javascript.

  • Typescript as its name adds type(s) enforcement which JS wont
  • Typescript has much neat easy to maintain
  • Typescript has cross-platform support

Typescript vs Javascript

Typescript

Javascript

Where typescript is used in automation testing ?

  • Well, its everywhere now wherever JS based framework is used, somewhere like
  • 1. AngularJS
  • 2. Protractor (testing tool for AngularJS app)
  • 3. Jasmine
  • 4. WebdriverIO

Here is the complete video of above discussion

Here is the Installation of Typescript video tutorial in Visual Studio Code Read more