ALL


  The Strange Behavior of the void Type in TypeScript

PrefaceIn TypeScript (TS), there is a type called void. It represents "nothing" but it's important to note that it's not the same as "nothing" in JavaScript(JS).Typically, void is used to declare the return type of functions. Although you can declare a variable as void, we generally don't do this because it serves no meaningful purpose. Let's explore why in the examples below.The void TypeDeclaring a Variable as voidlet name: void; // Declare a variable `name` with type `void`.name = 'nanjiu'; // Error: Cannot assign type 'string' to type 'void'.name = 18; // Error: Cannot assign type 'number'...

5,563 1       JAVASCRIPT TYPE TYPESCRIPT VOID


  Example on integrating TypeScript with Webpack

TypeScript is now a very popular language to create typed JavaScript code to reduce development error. It provides a type system on top of JavaScript which has only a weak type system. Once the TypeScript code is developed, it can be compiled into corresponding JavaScript so that they can be loaded and parsed by browser.Webpack is another tool for bundling multiple JS files into a single one so that no multiple connections to be established between browser and server. when a page is loaded This would reduce the bandwidth consumption and improve website performance in general.These two are good...

2,878 0       WEBPACK TYPESCRIPT JAVASCRIPT EXAMPLE