Typescript Interface [Typescript Tutorial]


An Interface is a description that defines specific methods that implements a class. Again, open your integrated terminal then type ng g interface <interfaceName> An Interface named Security is generated and ready for editing. A sample interface export interface Security { trade(); fairValueCompute(); } To use your interface, first you have to choose a class that will implement your interface. Let’s choose Bonds which we created earlier.   import {Security} from './security'; export class Bonds{ constructor(){ } getBonds(){ } } Import our interface named Security import {Security} from './security'; export class Bonds implements Security{ constructor() In the export class of Bonds, [...]

Typescript Interface [Typescript Tutorial]2017-03-29T06:45:34+00:00

TypeScript Classes [Typescript Tutorial]


The following is a simple TypeScript class defined. With TypeScript, unlike native JavaScript, there is a native class keyword. The following snippet illustrates a simple TypesScript class definition: class Person { fullname : string; constructor(public firstname, public middleinitial, public lastname) { this.fullname = firstname + " " + middleinitial + " " + lastname; } } Unlike the native JavaScript, TypeScript has a native class keyword. A public member, fullname and a public constructor that acquire three arguments: first, middle and last name. Through that constructor, the arguments are assembled to combine it to the public fullname member. JavaScript’s compiler looks [...]

TypeScript Classes [Typescript Tutorial]2017-03-18T06:45:41+00:00

Your First TypeScript File [Typescript Tutorial]


TypeScript requires extensions for its files. It uses either “.ts” or “.d.ts” // setBackgroundColor.ts. function setBackgroundColor() {     document.body.style.backgroundColor = "rgb(255,0,0)"; }     setBackgroundColor(); You might notice that it’s very similar to JavaScript. That’s because it is. Remember TypeScript is a superset of JavaScript. Pure JavaScript and the features of TypeScript that are declarative can be used. In the example, you can see the file is named as setBackgroundColor.ts Next, the image shows how TypeScript files compile resulting in a JavaScript file with the same name. These files are compiled from command line using tsc command. Here the .ts and .js are [...]

Your First TypeScript File [Typescript Tutorial]2017-03-09T07:59:08+00:00

What is TypeScript? [Typescript Tutorial]


What is TypeScript What is TypeScript? It is defined as Microsoft’s new offer that changes the way JavaScript is written. From the word from it’s name Type, it associates solid typed layer in synergy with JavaScript. It supports object-oriented programming layer unlike with JavaScript. What differs JavaScript? JavaScript’s nature is known to be functional rather than strongly typed or object-oriented. For most of programmers that are used with defining interface and classes, declaring integers, string or other variables, they might have some difficulty adjusting. In JavaScript, enforcing those integrities can be challenging enough. But you could always declare objects through prototyping. However, [...]

What is TypeScript? [Typescript Tutorial]2017-02-27T08:07:41+00:00

Introduction to TypeScript [TypeScript Tutorial]


TypeScript was conceptualized by Microsoft with the aim to modify the way we code with JavaScript. A TypeScript Class can be generated with Angular-CLI. In your IDE, open your terminal.  Go to View>Integrated Terminal. Now, type “ng g class <className>”. In our example, let’s use the name Bonds. A new class named Bonds is generated. In succeeding blog posts, we will give a more in-depth TypeScript tutorial.

Introduction to TypeScript [TypeScript Tutorial]2017-02-18T05:40:14+00:00

New Courses

Contact Info

Oxford St. Epping, Sydney, New South Wales, Australia 2121

Mobile: +61 499 802 855

Web: TutorialsDojo

Recent Posts

error: Content is protected !!