TypeScript 3.9

Return to TypeScript Version History, TypeScript, JavaScript


TypeScript 3.9, released in May 2020, brought several improvements and new features to the TypeScript language, focusing on performance enhancements, bug fixes, and developer productivity. This version aimed to make the language more robust and efficient, especially for large projects. Here, we summarize the key features and fixes introduced in TypeScript 3.9, including code examples and comparisons with similar features in other major languages like JavaScript, C#, Java, and Python. Additionally, links to essential 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. Improved Inference and Promise.all

TypeScript 3.9 improved type inference for `Promise.all`, making it easier to work with the results of multiple promises in a type-safe manner.

```typescript let [user, settings] = await Promise.all([fetchUser(), fetchSettings()]); ```

In JavaScript, `Promise.all` allows for parallel execution of promises but lacks static typing. C#'s `Task.WhenAll` offers similar functionality with type safety. Java's `CompletableFuture.allOf` provides parallel promise execution but requires more boilerplate for type safety. Python's `asyncio.gather` provides similar functionality but, like JavaScript, lacks built-in static typing.

  1. Speed Improvements in `tsc` and `–incremental`

TypeScript 3.9 introduced speed improvements in the TypeScript compiler (`tsc`), especially when using the `–incremental` flag, reducing build times for large projects.

```bash tsc –incremental ```

While this improvement is specific to TypeScript's compilation process, incremental compilation concepts are also found in compiled languages like C# and Java, which aim to reduce build times by compiling only changed parts of the codebase.

  1. `// @ts-expect-error` Comments

The `// @ts-expect-error` comment directive tells TypeScript to expect a compilation error on the next line, useful for testing or dealing with known issues.

```typescript // @ts-expect-error let x: number = “string”; ```

JavaScript does not have a built-in mechanism for this, as it is dynamically typed. C# and Java use annotations or pragmas for similar purposes, but not directly for expecting errors. Python's typing system does not have an equivalent feature.

  1. Improvements in Inference and `Promise.all`

TypeScript 3.9 made improvements in the type inference for `Promise.all`, enhancing the handling of tuple types for promises resolved in parallel.

```typescript let [user, settings] = await Promise.all([fetchUser(), fetchSettings()]); ```

This feature is unique to TypeScript's static type system and does not have direct equivalents in dynamically typed languages like JavaScript or Python. C# and Java offer similar promise and future handling mechanisms but with different syntactical approaches to type safety.

  1. Editor Performance Improvements

TypeScript 3.9 focused on improving the performance of the language services that power code editors, making the development experience smoother and faster, especially in large codebases.

While not directly related to language features, improvements in editor performance impact the developer experience across many programming environments, including those for C#, Java, and Python, where IDEs also focus on performance optimizations.

  1. New Syntax for Importing Types

TypeScript 3.9 introduced a new syntax for importing types, allowing developers to explicitly state when they are importing only types, which can be erased during compilation.

```typescript import type { User } from “./user”; ```

This syntax enhancement has no direct equivalent in JavaScript, as it pertains to TypeScript's static type system. C# and Java have distinct mechanisms for dealing with imports and type usage but nothing that directly corresponds to TypeScript's type-only imports. Python's type hints system, while offering some capabilities for type checking, does not require a separate syntax for type imports.

  1. `export * as ns` Syntax

TypeScript 3.9 added support for the `export * as ns` syntax from ECMAScript 2020, enabling more concise and readable module re-exports.

```typescript export * as utilities from “./utilities”; ```

JavaScript ES2020 introduced this syntax to simplify module re-exports. C# and Java handle module and namespace exports differently, typically through explicit class and interface exports. Python's module system uses import statements, but nothing akin to TypeScript's re-export syntax.

  1. Uncalled Function Checks

TypeScript 3.9 introduced checks for uncalled functions within conditions, helping to catch common errors where a function reference is used instead of calling the function.

```typescript if (myFunction) { // Error if myFunction is intended to be called

 // ...
} ```

JavaScript runs this code without error but might not behave as

expected. C# and Java both have compile-time checks that can catch similar mistakes. Python's dynamic nature means it does not perform such checks at runtime.

  1. Improvements to `?.` Operator

TypeScript 3.9 made improvements to the optional chaining operator (`?.`), aligning its behavior more closely with the ECMAScript standard and improving type checks.

```typescript let x = obj?.prop; ```

JavaScript ES2020 introduced optional chaining for handling undefined or null values gracefully. C# has the null-conditional operator that serves a similar purpose. Java and Python do not have built-in equivalents to this operator, requiring more verbose null checks.

  1. Support for `export * as ns` from ECMAScript 2020

TypeScript 3.9 added full support for the `export * as ns` syntax, a feature from ECMAScript 2020 that allows for more expressive module exports.

```typescript export * as Utils from “./utils”; ```

This syntax is specific to ECMAScript modules and does not have direct equivalents in C#, Java, or Python, which have their own systems for modules and namespaces.

  1. Conclusion

TypeScript 3.9 focused on enhancing the language's performance, developer experience, and type safety, with significant improvements in compilation speed, editor responsiveness, and static type checking. Through features like the `// @ts-expect-error` comment, improved `Promise.all` typing, and new import/export syntaxes, TypeScript continues to provide developers with powerful tools for building complex and robust applications. Comparing these features to similar ones in languages like C#, Java, and Python highlights TypeScript's unique position in leveraging JavaScript's dynamic capabilities while offering the benefits of static typing. The version's focus on both language features and tooling improvements ensures that TypeScript remains an indispensable tool for developers working in the diverse ecosystem of JavaScript and beyond.


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.