Skip to content

Legacy vs. Current JS

Andy Mc edited this page Jun 24, 2021 · 1 revision

Legacy JS (For <= EE5)

The JS for the EE5 and older CP is still being used (as of the time of this writing) and is included in the build process for the minified file. The Legacy JS is being migrated from regular Javascript over to TypeScript.

Location

The source files for the legacy JS live here: /themes/ee/asset/javascript/src/

Current JS

As we migrate from the Legacy JS to the Current JS, we are converting pieces from regular Javascript to Typescript and changing the location of those files.

Location

The source files for the current JS live here: /themes/ee/cp/js/src/

Why TypeScript?

TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. The goal of TypeScript is to help catch mistakes early through a type system and to make JavaScript development more efficient.

TypeScript allows for the use of many of the latest ECMAScript features and translates them to older ECMAScript targets of your choosing. This means that you can safely use new features, like modules, lambda functions, classes, the spread operator and destructuring, while remaining backwards compatible with older browsers and JavaScript runtimes.

TypeScript has a unique philosophy compared to other languages that compile to JavaScript. JavaScript code is valid TypeScript code; TypeScript is a superset of JavaScript. You can almost rename your .js files to .ts files and start using TypeScript. TypeScript files are compiled to readable JavaScript, so that migration back is possible and understanding the compiled TypeScript is not hard at all. TypeScript builds on the successes of JavaScript while improving on its weaknesses.

Source: https://stackoverflow.com/a/35048303