TypeScript 3.4

Return to TypeScript Version History, TypeScript, JavaScript


TypeScript 3.4, released in March 2019, introduced several notable features and improvements aimed at enhancing developer productivity, optimizing performance, and extending the language's capabilities for type manipulation and runtime behavior. This version continued TypeScript's commitment to align closely with ECMAScript standards while providing powerful tools for large-scale application development. Below is an overview of the main features and enhancements introduced in TypeScript 3.4, along with comparisons to similar features in other programming languages. Additionally, essential links to TypeScript resources are provided.

- Language Documentation: [TypeScript Documentation](https://www.typescriptlang.org/docs/) - GitHub Repository: [TypeScript GitHub](https://github.com/microsoft/TypeScript) - Official Website: [TypeScript](https://www.typescriptlang.org/) - Wikipedia: [TypeScript Wikipedia](https://en.wikipedia.org/wiki/TypeScript)

  1. Incremental Builds (`–incremental`)

TypeScript 3.4 introduced the `–incremental` flag, significantly reducing subsequent build times by saving information about the project graph from the last compilation. This feature marks TypeScript's continued efforts to improve developer experience through faster compilation times.

```bash tsc –incremental ```

Incremental compilation is a concept found in many programming languages, such as C# (with MSBuild) and Java (with tools like Gradle), to improve build performance. Python's interpreted nature means it doesn't compile in the same way, but similar concepts exist in tools like `mypy` for type checking.

  1. `const` Assertions

TypeScript 3.4 introduced `const` assertions. By using `as const`, developers can signal to the compiler that no literal types in an object should be widened (e.g., string literals should not be widened to `string`), and objects should be treated as readonly.

```typescript let example = {

 name: "TypeScript",
 version: 3.4
} as const; ```

JavaScript does not have a direct equivalent since it does not support type annotations. C# has `readonly` modifiers and `const` for compile-time constants. Java has `final`. Python uses type comments or type annotations (PEP 484) for similar purposes but does not have built-in immutability enforcement.

  1. Type-Checking for `globalThis`

TypeScript 3.4 added support for `globalThis`, providing a standardized way to access the global `this` value with type safety. This addition aligns TypeScript with the ECMAScript proposal for a consistent global namespace object.

```typescript console.log(globalThis); ```

`globalThis` is a standardization effort in ECMAScript, thus JavaScript. C# uses `global` in a different context. Java and Python do not have a direct equivalent because they have different runtime environments and scoping rules.

  1. Higher Order Type Inference from Generic Functions

TypeScript 3.4 improved type inference in higher-order functions, allowing for more precise typing in common patterns, particularly with functions that return functions or take functions as arguments.

```typescript function compose<A, B, C>(f: (a: A) ⇒ B, g: (b: B) ⇒ C): (a: A) ⇒ C {

 return x => g(f(x));
} ```

C#'s and Java's generics provide similar capabilities for type inference in higher-order functions. Python's typing module introduced in Python 3.5 offers generics and function overloads through `typing`, but with less powerful type inference capabilities.

  1. ReadonlyArray and Readonly Tuples

TypeScript 3.4 made it possible to specify arrays and tuples as readonly, preventing assignments to indices and ensuring the immutability of the data structure.

```typescript function exampleFunction(items: readonly string[]) {

 // items.push("hello"); // Error: push does not exist on readonly arrays
} ```

JavaScript arrays are mutable by nature, and immutability can only be enforced at runtime. C# has `ReadOnlyCollection<T>`. Java offers unmodifiable collections through `Collections.unmodifiableList`. Python achieves immutability through tuple data structures, but without static type enforcement.

  1. `readonly` and Mapped Types

Building on readonly capabilities, TypeScript 3.4 allows the `readonly` modifier to be used in mapped types, making it easier to create immutable versions of existing types.

```typescript type ReadonlyPerson = { readonly [K in keyof Person]: Person[K] }; ```

C#'s record types in C# 9.0 and onwards offer similar immutability features. Java's record (Java 14 and later) provides immutable data carriers. Python's data classes (with `frozen=True`) provide immutability for class instances, but without TypeScript's compile-time type safety.

  1. Conclusion

TypeScript 3.4 continued to push the boundaries of what developers can achieve with static types in JavaScript, providing tools to write safer, more maintainable code. Features like incremental builds, `const` assertions, and improved

type inference enhance the language's usability and performance. Comparing these features with those in C#, Java, and Python underscores TypeScript's unique position in leveraging JavaScript's flexibility while offering the robustness of a statically typed language. These advancements demonstrate TypeScript's commitment to evolving in response to community feedback and the changing landscape of web development, ensuring it remains a powerful tool for developers worldwide.


TypeScript Version History: TypeScript, JavaScript. TypeScript 4.7 (2022), TypeScript 4.6 (2022), TypeScript 4.5 (2021), TypeScript 4.4 (2021), TypeScript 4.3 (2021), TypeScript 4.2 (2021), TypeScript 4.1 (2020), TypeScript 4.0 (2020), TypeScript 3.9 (2020), TypeScript 3.8 (2020), TypeScript 3.7 (2019), TypeScript 3.6 (2019), TypeScript 3.5 (2019), TypeScript 3.4 (2019), TypeScript 3.3 (2019), TypeScript 3.2 (2018), TypeScript 3.1 (2018), TypeScript 3.0 (2018), TypeScript 2.9 (2018), TypeScript 2.8 (2018), TypeScript 2.7 (2018), TypeScript 2.6 (2017), TypeScript 2.5 (2017), TypeScript 2.4 (2017), TypeScript 2.3 (2017), TypeScript 2.2 (2017), TypeScript 2.1 (2016), TypeScript 2.0 (2016), TypeScript 1.8 (2016), TypeScript 1.7 (2015), TypeScript 1.6 (2015), TypeScript 1.5 (2015), TypeScript 1.4 (2015), TypeScript 1.3 (2014), TypeScript 1.1 (2013), TypeScript 1.0 (2012). (navbar_typecript_versions - see also navbar_typescript, navbar_javacript_versions

TypeScript: TypeScript Glossary, TypeScript Best Practices, Web Development Best Practices, JavaScript Best Practices, TypeScript Fundamentals, TypeScript Inventor - TypeScript Language Designer: Anders Hejlsberg of Microsoft on October 1, 2012; TypeScript Keywords, TypeScript Built-In Data Types, TypeScript Data Structures - TypeScript Algorithms, TypeScript Syntax, TypeScript on Linux, TypeScript on macOS, TypeScript on Windows, TypeScript on Android, TypeScript on iOS, TypeScript Installation, TypeScript Containerization (TypeScript with Docker, TypeScript with Podman, TypeScript and Kubernetes), TypeScript OOP - TypeScript Design Patterns, Clean TypeScript - TypeScript Style Guide, TypeScript Best Practices - TypeScript BDD, Web Browser, Web Development, HTML-CSS, TypeScript Frameworks (Angular), JavaScript Libraries (React.js with TypeScript, Vue.js with TypeScript, jQuery with TypeScript), TypeScript on the Server (TypeScript with Node.js, TypeScript with Deno, TypeScript with Express.js), TypeScript Compiler (tsc, tsconfig.json), TypeScript Transpiler (Transpile TypeScript into JavaScript), Babel and TypeScript, TypeScript Package Management, NPM and TypeScript, NVM and TypeScript, Yarn Package Manager and TypeScript, TypeScript IDEs (Visual Studio Code, Visual Studio, JetBrains WebStorm), TypeScript Development Tools, TypeScript Linter, TypeScript Debugging (Chrome DevTools, JavaScript Source Maps), TypeScript Testing (TypeScript TDD, Selenium, Jest, Mocha.js, Jasmine, Tape Testing (tap-producing test harness for Node.js and browsers), Supertest, React Testing Library, Enzyme.js React Testing, Angular TestBed), TypeScript DevOps - TypeScript SRE, TypeScript Data Science - TypeScript DataOps, TypeScript Machine Learning, TypeScript Deep Learning, Functional TypeScript, TypeScript Concurrency (WebAssembly - WASM) - TypeScript Async (TypeScript Await, TypeScript Promises, TypeScript Workers - Web Workers, Service Workers, Browser Main Thread), TypeScript Concurrency, TypeScript History, TypeScript Bibliography, Manning TypeScript Series, TypeScript Glossary, TypeScript T, TypeScript Courses, TypeScript Standard Library, TypeScript Libraries, TypeScript Frameworks (Angular), TypeScript Research, JavaScript, TypeScript GitHub, Written in TypeScript, TypeScript Popularity, TypeScript Awesome, TypeScript Versions. (navbar_typescript - see also navbar_javascript, navbar_javascript_libraries, navbar_typescript_libraries, navbar_typescript_versions, navbar_typescript_standard_library, navbar_typescript_libraries, navbar_typescript_reserved_words, navbar_typescript_functional, navbar_typescript_concurrency, navbar_typescript_async, navbar_javascript_standard_library, navbar_react.js, navbar_angular, navbar_vue, navbar_javascript_standard_library, navbar_web_development)


© 1994 - 2024 Cloud Monk Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.