According to TypeScript’s website, three of TypeScript’s major strengths are:
The Dojo 2 project has taken advantage of each of these strengths to achieve its goals.
Every framework makes design decisions based on the project’s goals. The best framework for a given project is often the one whose design goals most closely match the needs of the project.
Dojo 2 was designed to address the needs of large-scale, enterprise applications. To meet this single overarching target, several smaller goals need to be achieved.
- Dojo 2 needs to ensure that applications can be developed efficiently, scaled smoothly, and maintained easily.
- It must simplify the creation of data-centric applications that are common in many enterprises.
- It must provide out-of-the-box support for features that are important to enterprises such as accessibility (a11y), internationalization (i18n), and security.
TypeScript offers many features that have enabled Dojo 2 to realize its objectives. Three of the primary features are: the type system, interfaces, and the transpiler.
TypeScript includes an optional type system that addresses these issues. The type system allows engineers to describe the data and behaviors that make up an application. This allows an individual engineer to interact with code written by someone else more efficiently. As a result, they can spend more time working on their own features, rather than trying to understand someone else’s code.
The type system also allows tools to increase a engineer’s productivity by letting them know what data types are expected within the application. Features like code completion, refactoring support, and static analysis help to ensure that the engineer is using the existing aspects of the application correctly. This allows the engineer to spend more time authoring code and less time reading. Additionally, since the type system provides design-time warnings about incompatible types, type assertion tests can be eliminated from the application’s test suite.
One of the concerns that many engineers have about adding types to a language is the additional code that must be authored to satisfy the transpiler. This can reduce engineer efficiency since time spent authoring typing information cannot be devoted to authoring new features. To address this, TypeScript uses type inference to limit the amount of extra code needed to define the data types.
A final advantage that the type system brings is the ability to identify aspects of an application that are not required. By identifying code that is unreachable, variables that are unused, and imported modules that are not accessed, it is easier to locate and remove stale code from a TypeScript application. This makes applications easier to maintain by reducing technical debt.
Many enterprise-level applications are too large to be authored by a single engineer or even a single team. To manage these projects, enterprises seek to divide large projects among multiple teams. Doing this, however, creates challenges as each team must often be able to share APIs and data with other teams. TypeScript’s allows interfaces that can simplify these coordination efforts. A TypeScript interface can be used to describe the methods that a class must support or the shape of a data structure. By setting up interfaces between development teams, each team can be confident that their code will be compatible the code from other teams.
In addition to supporting team-coordination, the ability to describe a data structure’s expected shape clarifies the expected fields within object literals. This is especially important when creating applications that interact with a server to load, manipulate, and save large amounts of data. Since communication between Dojo 2 applications and servers is typically done using the JSON protocol, the ability to define interfaces for the messages greatly simplifies the processing of that data.
TypeScript’s type system has allowed powerful development aids to be created such as refactoring tools and autocompletion support. This enables enterprise engineers to focus on authoring clean, efficient code without having to memorize or look up the details for existing APIs.
Dojo 2 has been designed to continue the legacy of Dojo 1 - support the development of robust, maintainable, data-rich enterprise applications. By leveraging TypeScript’s type system, interfaces, and the transpiler’s ability to use cutting edge features in backward compatible ways, it forms the solid foundation that Dojo 2 is using to enable the next generation of applications to be built with world-class levels of performance, maintainability, and reliability.