WHAT’S NEW IN TYPESCRIPT 2.6

What’s New in TypeScript 2.6

New in TypeScript 2.6

Microsoft’s TypeScript language is an added superset of JavaScript, designed to handle the needs of challenging programs worked on by there teams.

Microsoft’s TypeScript language is an added superset of JavaScript, designed to handle the needs of challenging programs worked on by there teams.

WHAT’S NEXT IN TYPESCRIPT 2.7?

TypeScript 2.7 is due in January 2018 and will feature improved type inference for object literals. The major reason for this upgrade to support both the JSX fragment syntax and properties named with const- declared symbols. An increased builder compiler API is also planned.

At some point perhaps beyond TypeScript 2.7, the language is slated to support project references and provision of specific types of variadic functions.

WHAT’S NEW IN THE CURRENT VERSION TYPESCRIPT 2.6?

TypeScript 2.6 is presented as a strict mode flag, which is identified as strictFunctionTypes. In strict mode, any function type that does not originate from a method has its parameters compared as contravariant. TypeScript usually compared as a parameter in a “bivariant” manner, allowing for benefits such as a simpler model for working with arrays. TypeScript 2.6 offers an increasing strictness on all function types except methods.

ERROR SUPPRESSION COMMENTS WITH // @TS-IGNORE:

Traditionally, we have avoided error suppression within TypeScript because in most cases the users asked for it could be solved through more accurate declaration files, or using a type assertion to any.

For the prior one, the benefits are obvious: the developer wants to start moving over to TypeScript, but he/she has to run into a pattern that is particularly difficult to model. The developer might spend time trying to understand it, but maybe he/she would rather get rid of it later on anyway, so to just avoid errors because the code will still run fine.

The latter situation is a bit less clear. The impetus here was that within some large companies, dependencies across projects are updated in tandem, including TypeScript itself and @types declaration files from Definitely Typed. If any change is done the developer gets a type-checking error, someone has to fix that to elude the breaking build. But now a question arises: Who can do this?

The TypeScript 2.6 is bringing // @ts-ignore comments to TypeScript files. These comments suppress any errors that occur on the next line. For instance, in the following code, TypeScript would ordinarily report an error about the console.log statement being unreachable. In TypeScript 2.6, the // @ts-ignore comment flattens the error entirely.

if (false) {

// @ts-ignore: Unreachable code error

console.log(“hello”);

}

BREAKING CHANGES AND DEPRECATIONS

There are several minor changes that may impact the codebase.

Write only references are now considered unused under — noUnusedLocals and –noUnusedParameters.

In ambient contexts such as declaration files, and declare module blocks, expressions are now rejected in defaultexports.

Uninhabitable types resulting from intersections will simplify to never when placed in a union.

Various changes have been made to DOM declarations in lib.d.ts.

WHAT’S NEW IN ANGULAR 5

What’s New in Angular 5

Angular 5

Angular is an all-encompassing JavaScript framework that is recurrently used by the developers all over the world for building web, desktop, and mobile applications. In this article, we will be covering the new features in Angular 5 and several other changes.

The update from AngularJS to Angular 2 was a very big step forward, but it was also ill-famed for not being backward compatible. In contrast, Angular 4 brought new features despite the fact being backward compatible. And now, six months later, the latest major release is available.

The upgrade to Angular 5 is a new increased version. Many of the changes are done in this version are invisible.

The major focus of Angular 5 is to make Angular faster.

TYPESCRIPT 2.4 SUPPORT IN ANGULAR 5

Angular 5 now formally supports TypeScript version 2.4. Previous versions of Angular have supported TypeScript 2.3 without errors since release 4.3, including the Strict-Null-Check option.

Below are the some of the key features from the latest TypeScript:

String-based enums are a new feature introduced in TypeScript 2.4. This means that the members of an enum can now be expressed with a string instead of a number. Let’s see an example below.

enum Colors {Red = “RED”, Green = “GREEN”, Blue = “BLUE”,}

Note that in this look, string enums cannot be mapped backward like their number-based relatives. Therefore, a query like Colors [“RED”] is not possible to catch the string “Red”.

Also, the latest version of TypeScript advances type checking with regards to generics.

On the other hand, type checking is becoming stricter and the return types of generic functions can now also be inferred. For instance, the subsequent call leads to an error:

let foo: Promise = new Promise(resolve => {
resolve(“bar”);
// Error
});

Another development is the so-called Weak-Type-Detection. Types are weak if they only own optional parameters which can now be detected. Here is an example of this kind of type:
export interface Options {
showSideNav?: boolean;
description?: string;
}

BUILD

Even for advanced web applications, updates in the framework are not enough, the build tooling has to be extended.

This is exactly what happens with Angular-CLI in other areas. The static analysis of the AOT mode is partly done in the normal build. Thus, many errors are noticed earlier at build time and not at runtime.
The AOT mode has also been fast-tracked in order to support incremental builds and significantly reduce built time.

For faster builds, a build tool from Google called Bazel can be integrated. However, it is still in a very initial stage of development at the moment. In the future, the Google Closure Compiler can also be used more rigorously to achieve more optimized build results.

FORMS

To improve performance, the developer can now specify when validators should be executed in forms.

Every time a FormControl value is changed, the validation will be performed accordingly – potentially with every major element. In the case of more difficult validations, this can lead to an unusual worse performance.

With the new updateOn option, Angular 5 also allows the developer to specify more exactly when this validation should be performed. The developer can select change, which requires the previous behaviour, submit or blur options.

USAGE WITH TEMPLATE-DRIVEN FORMS

For forms that are defined through a template, the updateOn parameter presented with Angular 5 can also be stated. This is done at ngModelOptions, as shown in the below example:

<input type=”email” ngModel [ngModelOptions]=”{updateOn: ‘submit’}”>

Here the setting is inherited from the element interleaving in the DOM. In the following example, the setting is made directly in the element of the form:

<form [ngFormOptions]=”{updateOn: ‘submit’}”>

<input name=”email” ngModel type=”email”>

<input name=”password” ngModel type=”email”>

</form>

A subordinate element can overwrite the default value just as reactive forms.

<form [ngFormOptions]=”{updateOn: ‘submit’}”>

<input name=”email” ngModel type=”email” [ngModelOptions]=”{updateOn: ‘blur’}”>

<input name=”password” ngModel type=”email”>

</form>

ROUTER

The Angular Router has been stretched with additional events. Now, for example, the developer can create progress displays that will display when a route is changed. The corresponding events are ActivationStart and ActivationEnd or ChildActivationStart and ChildActivationEnd.

router.events

// Event = RouteEvent | RouterEvent

.filter(e => e instanceof RouteEvent)

.subscribe(e => {

if (e instanceof ActivationStart) {

spinner.start();

} else if (e instanceof ActivationEnd) {

spinner.end()

}

});

THE VERDICT

Angular 5 came with new features and major enhancements. It is smaller and faster. We are very happy with what

the Angular team achieved with this release.

Have you switched to Angular 5 yet? What are your opinions? Did you notice any major enhancements? Try and let us know your opinion on the new upgrade of Angular.

NEW AWS ECS KUBERNETES RELEASE

New AWS ECS Kubernetes Release

New AWS ECS Kubernetes Release

There are a lot of AWS customers who run Kubernetes on AWS. In fact, according to the publishes, 63% of Kubernetes workloads run on AWS. While AWS is a popular place to run Kubernetes, there is still a lot of manual configuration that customers need to manage their Kubernetes clusters. The user has to install and operate the Kubernetes master and configure a cluster of Kubernetes workers. In order to achieve high availability in Kubernetes clusters, the user has to run at least three Kubernetes masters across different AZs. Each master needs to be configured, consistently share information, load balance, and fail-over to the other masters if one experiences a failure. Then once the user has all set up, the user still has to deal with upgrades and patches of the masters and workers software. Explore this article and know more about AWS ECS Kubernetes release.

ABOUT AMAZON EKS

Amazon Elastic Container Service for Kubernetes (Amazon EKS) is a completely managed service that makes it easy for the user to use Kubernetes on AWS without having to be a proficient in managing Kubernetes clusters. There are few points that developers will really like about this service. Firstly, Amazon EKS runs the upstream version of the open-source Kubernetes software, so the user can use all the standing plugins and tooling from the Kubernetes community. The users can easily migrate their Kubernetes applications to Amazon EKS with zero code changes. Secondly, Amazon EKS spontaneously runs K8s with three masters across three AZs to protect against a single point of failure. This multi-AZ architecture provides resiliency against the loss of an AWS Availability Zone.

Thirdly, Amazon EKS also automatically detects and replaces unhealthy masters, and it provides automatic version upgrades and patching for the masters. The Amazon EKS joins with Amazon features like Elastic Load Balancing for load distribution, IAM for authentication, Amazon VPC for isolation, and AWS Cloud Trail for logging.

HOW IT ACTUALLY WORKS

Amazon EKS integrates IAM authentication with Kubernetes RBAC in association with Heptio. The user can assign RBAC roles to every individual IAM entity allowing the user to control the access authorizations to their Kubernetes masters. This allows the users to easily manage their Kubernetes clusters using Kubernetes tools such as Kubectl.

The user can also use a private link if he/she wants to access their Kubernetes masters directly from their Amazon virtual private cloud. This process lets the users access their Kubernetes masters and Amazon EKS straight from their own Amazon VPC without using public IP address.

Lastly, an open source CNI plugin that anyone can use with their Kubernetes clusters on AWS. This allows the user to natively use Amazon VPC networking with their Kubernetes pods. With Amazon EKS, introducing a Kubernetes cluster is as easy as a few clicks in the AWS Management Console. Amazon EKS handles the rest, the improvements, fixing, and high availability.

TOP MISTAKES DEVELOPERS DO WHILE CODING WITH ANGULAR

Top Mistakes Developers Do While Coding with Angular

Top Mistakes Developers Do While Coding with Angular

AngularJS is one of the most popular JavaScript frameworks accessible today. AngularJS major goal is to bridge the development process which makes it great for prototyping small applications, but its power allows scaling to full-featured client-side applications. The combination affluence of development, breadth of features, and performance has led to wide implementation, and wide implementation comes with many common drawbacks. This list captures common AngularJS mistakes, so explore this article and know the major mistakes done by developers while coding with Angular.

USING NGONCHANGES TO SPOT QUERY LIST CHANGES

In Angular 1, if the user wanted to be notified when a value changed, the user has to set a $scope.$watch and physically check for changes in each digest cycle. In Angular 2, the ngOnChanges links greatly and streamlines this process. Once the user defines a ngOnChanges method in his/her component class, it will be called whenever the component’s inputs change.

But, the ngOnChanges method executes only when the component’s inputs change -especially, those items the user have included in his/her inputs array or explicitly labeled with an @Input decorator. It will not be called when items are added or removed from @ViewChildren or @ContentChildren query lists.

If the user wants to be alerted for changes in a query list, then the user should not use ngOnChanges. In its place, the user should subscribe to the query list’s built-in observable, it “changes” property. As long as the user do so in the proper lifecycle link, the user will be alerted whenever an item is added or removed.

@Component({ selector: ‘my-list’ })
export class MyList implements AfterContentInit {
@ContentChildren(ListItem) items: QueryList;

ngAfterContentInit() {
this.items.changes.subscribe(() => {
// will be called every time an item is added/removed
});
}
}
CALLING DOM APIS DIRECTLY

There are very few circumstances where manipulating the DOM directly is necessary. Angular 2 provides a set of leading, high-level APIs such as queries that one can use instead. Leveraging these APIs confers distinct advantages:

  • It is possible to unit test the application without touching the DOM, which removes difficulty from testing and helps the user tests run faster.
  • It decouples the user’s code from the browser, allowing the user to run the application in any rendering context, such as web workers or outside of the browser completely.

When the user manipulates the DOM manually, the user will miss out the above advantages and ultimately end up writing less expressive code.

QUERY RESULTS IN THE CONSTRUCTOR

While playing around with queries, it is easy to fall into this ploy.
@Component({…})
export class MyComp {
@ViewChild(SomeDir) someDir: SomeDir;
constructor() {
console.log(this.someDir);    // undefined
}
}

When the console logs are “undefined”, the developer might assume the query is not working or the developer itself constructed it imperfectly. It is important to remember that query results are not yet available when the constructor executes.

BINDING TO THE NATIVE “HIDDEN” PROPERTY

In Angular 1, if the user wants to adjust the visibility of an element, the user can use one of the Angular’s built-in directives, such as ng-show or ng-hide

Angular 1 example:

<div ng-show=”showGreeting”>

Hello, there!

</div>

In Angular 2, template syntax makes it available to bind to any native property of an element. This is very powerful and opens up a number of possibilities. One option to bind to the native hidden property, which is similar to ng-show, and sets the display to “none”.

Angular 2 [hidden] example:

<div [hidden]=”!showGreeting”>

Hello, there!

</div>

At first sight, binding to the hidden property seems like the closest cousin to Angular 1 ng-show. However, there is one “!important” difference.

ng-show & ng-hide together handles visibility by adjusting “ng-hide” CSS class on the element, which sets the show property to “none” when applied. Importantly, Angular controls this style and postscripts it with “!important” to assure that it always overrides any other display styles set on that element.

THE VERDICT

AngularJS is a great framework that continues to grow with the community. AngularJS is still a growing concept, but hopefully by following these pacts some of the major pitfalls of scaling an AngularJS can be averted.

MICROSOFT CONSIDERS ADDING PYTHON AS AN OFFICIAL SCRIPTING LANGUAGE TO EXCEL

Microsoft Considers Adding Python as an Official Scripting Language to Excel

According to a topic on Excel’s feedback hub published few days back, Microsoft considers adding Python to Excel. This topic has turned out to be the vastly voted feature request, ever since the news was on the hub.

PYTHON TURNS DIFFICULTY TO SIMPLICITY

Python is one of the most popular programming languages among developers, due to its easiness in coding and its flexibility. To know where it ranks while compared to other programming languages, Python ranks second on the PYPL programming languages ranking. According to the RedMonk Programming Language Rankings, it ranks third, and fourth in the TIOBE index.

If Python for Excel is approved by Microsoft, one can easily work with Excel documents, Excel data, and with its core functions, using Python scripts replacing the current VBA scripts.

This Python scripting, would not only turn out to be a replacement for VBA but also could be a replacement for field functions (=SUM(A1:A2)).

The idea of having Python as an official Excel scripting language was highly appreciated by many users on board. Moreover, the users also marked that if Microsoft goes forward in wiring Python within Excel, they also would require Python in other Microsoft Office apps.

After watching the news on the hub, many users and developers said that Microsoft should definitely choose Python and during this process, it should also decide whether it would be Python with a .Net library–which has separate standard and core libraries–or IronPython. Later, this has to be done in a process that provides exactly same libraries and user-written code to work in the same way throughout other Microsoft Office products.

Though Microsoft would be elated in adding such a feature for their users, still, not much information is known about this project. Until then we can expect great bombshells from Microsoft with user side benefits.

WHY DO WE USE PIPELINES IN JENKINS?

Why do we use Pipelines in Jenkins?

Pipeline adds a powerful set of automation tools onto Jenkins, supporting use cases that span from simple continuous integration to comprehensive continuous delivery pipelines. By modeling a series of related tasks, users can take advantage of the many features of Pipeline.

Code: Pipelines are implemented in code and typically checked into source control, giving teams the ability to edit, review, and iterate upon their delivery pipeline.

Durable: Pipelines can survive both planned and unplanned restarts of the Jenkins master.

Pausable: Pipelines can optionally stop and wait for human input or approval before continuing the Pipeline run.

Versatile: Pipelines support complex real-world continuous delivery requirements, including the ability to fork/join, loop, and perform work in parallel.

Extensible: The Pipeline plugin supports custom extensions to its DSL and multiple options for integration with other plugins.

HOW TO SAVE S3 OBJECT TO A FILE USING BOTO3?

How to save S3 object to a file using boto3?

Advantages:
s3_client = boto3.client(‘s3′)
open(‘hello.txt’).write(‘Hello, world!’)
# Upload the file to S3
s3_client.upload_file(‘hello.txt’, ‘MyBucket’, ‘hello-remote.txt’)
# Download the file from S3
s3_client.download_file(‘MyBucket’, ‘hello-remote.txt’, ‘hello2.txt’)
print(open(‘hello2.txt’).read())
These functions will automatically handle read/write files as well as doing multipart uploads in parallel for large files.

HOW TO CHECK IF A KEY EXISTS IN S3 BUCKET USING BOTO3 ?

How to check if a key exists in s3 bucket using boto3?

import boto3
import botocore

s3 = boto3.resource(‘s3′)

try:
s3.Object(‘my-bucket’, ‘dootdoot.jpg’).load()
except botocore.exceptions.ClientError as e:
if e.response[‘Error’][‘Code’] == “404”:
# The object does not exist.

else:
# Something else has gone wrong.
raise
else:
# The object does exist.Load() does a HEAD request for a single key, which is fast, even if the object in question is large or you have many objects in your bucket.

Of course, you might be checking if the object exists because you are planning on using it. If that is the case, you can just forget about the load() and do a get() or download_file() directly, then handle the error case.

HOW TO CREATE A BACKUP AND COPY FILES IN JENKINS?

How to create a backup and copy files in Jenkins?

To create a backup, all you need to do is to periodically back up your JENKINS_HOME directory. This contains all of your build jobs configurations, your slave node configurations, and your build history. To create a back-up of your Jenkins setup, just copy the directory.