25 Game-chang­ing javascript tools

net magazine - - CONTENTS -

Matt Crouch details a mixed set of tools that will ease the cre­ation of your next Java Script project

type­script­lang.org A com­mon is­sue for new JavaScript de­vel­op­ers is its dy­namic typ­ing sys­tem. A vari­able type can be in­ferred at run­time but will have no re­stric­tion as to what type it can be in the fu­ture.

Dy­namic typ­ing can be use­ful in cre­at­ing pat­terns, but how use­ful that is de­pends on the project. TypeScript aims to bring a declar­a­tive style of pro­gram­ming by typ­ing vari­ables where de­vel­op­ers feel it makes sense.

Type an­no­ta­tions ap­pear where a vari­able is de­fined. With ob­jects, in­ter­faces de­fine the struc­ture of an object and the type be­comes a ref­er­ence to that in­ter­face. These can be ex­tended to cre­ate eas­ily cus­tomised ob­jects. TypeScript uses ex­per­i­men­tal JavaScript syn­tax as part of its sys­tem. Dec­o­ra­tors, for ex­am­ple, are func­tions that ap­ply them­selves to a class, method or prop­erty that pro­vide re­peat­able func­tion­al­ity. These can save du­pli­ca­tion in a project.

It also com­piles ex­ist­ing syn­tax such as classes, mod­ules and ar­row func­tions into valid ES3 or ES5. This can be cus­tomised to the browsers tar­geted within each project. When browsers can na­tively sup­port these fea­tures, TypeScript can be in­structed to keep them, mak­ing the re­sult­ing code per­form bet­ter.

TypeScript is a su­per­set of JavaScript, so pro­vides ben­e­fits to the lan­guage with­out chang­ing its struc­ture. As a re­sult, any JavaScript is valid TypeScript and any of its fea­tures used are com­pletely op­tional.

Above When it com­piles, TypeScript can tar­get any ver­sion of JavaScript re­quired for each project

Newspapers in English

Newspapers from Australia

© PressReader. All rights reserved.