User Tools

Site Tools


typescript_3.5

TypeScript 3.5

Return to TypeScript Version History, TypeScript, JavaScript


TypeScript 3.5, released in May 2019, introduced several key features aimed at improving the language's type-checking capabilities, optimizing compiler performance, and enhancing developer productivity. This version focused on making TypeScript more efficient and user-friendly while maintaining compatibility with the evolving JavaScript ecosystem. Below is a detailed overview of the main features and improvements in TypeScript 3.5, along with comparisons to similar features in other major programming languages. 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. The `Omit` Helper Type

TypeScript 3.5 introduced the `Omit` helper type, allowing developers to create an object type that omits specified properties from another type. This utility is particularly useful for object type manipulation and composition.

```typescript interface Person {

 name: string;
 age: number;
 location: string;
}

type PersonWithoutLocation = Omit<Person, 'location'>; ```

While JavaScript lacks static types and thus has no direct equivalent, C# offers similar capabilities through anonymous types or by using reflection. Java can achieve similar results using subclasses or interfaces. Python's `TypedDict` in the typing module allows for similar constructs but doesn't directly support an `Omit` equivalent without custom utility functions.

  1. Improved Type Checking for `–strictPropertyInitialization`

TypeScript 3.5 enhanced type checking for class properties under `–strictPropertyInitialization`, ensuring that all instance properties are correctly initialized in the constructor. This feature helps catch uninitialized properties that could lead to runtime errors.

```typescript class Person {

 name: string; // Error under --strictPropertyInitialization if not initialized
 constructor(name: string) {
   this.name = name;
 }
} ```

C# has nullable reference types to address uninitialized properties. Java ensures property initialization through constructor checks. Python, being dynamically typed, relies on runtime checks or static analysis tools for similar validations.

  1. Speed Improvements in the Compiler and Language Service

TypeScript 3.5 focused on optimizing compiler and language service operations, reducing the time required for type-checking and error detection, especially in projects with complex type structures.

This optimization is specific to TypeScript's implementation. However, all major programming languages, including C#, Java, and Python, continually work on compiler and tooling performance to improve developer experience.

  1. The `–allowUmdGlobalAccess` Flag

The `–allowUmdGlobalAccess` flag in TypeScript 3.5 allows global access to UMD (Universal Module Definition) modules, facilitating easier use of libraries that export their APIs globally under the UMD pattern.

```typescript // With –allowUmdGlobalAccess enabled const myLib = myUmdGlobalLib; ```

JavaScript supports UMD patterns natively. C# and Java manage global access through different mechanisms, like namespaces and classpath scanning. Python uses module imports, with no direct UMD equivalent.

  1. Smarter Union Type Checking

TypeScript 3.5 improved union type checking, making it more efficient and accurate, especially when discriminating union types with common properties.

```typescript type Shape = Circle | Square; function getArea(shape: Shape) {

 if ('radius' in shape) {
   return Math.PI * shape.radius ** 2;
 } else {
   return shape.sideLength ** 2;
 }
} ```

This feature leverages TypeScript's advanced type system, which has no direct equivalent in JavaScript. C#'s pattern matching, Java's `instanceof` checks, and Python's type hints with `Union` offer similar, though not directly comparable, functionalities.

  1. Incremental Type-Checking with the `–incremental` Flag

The `–incremental` flag in TypeScript 3.5 introduced the ability to perform incremental type-checking, caching certain results from previous compilations to speed up subsequent builds.

```bash tsc –incremental ```

Incremental compilation is common in C# and Java build systems (e.g., Roslyn, javac) to improve build performance. Python's interpreted nature means it doesn't benefit from incremental type-checking in the same way, though tools like `mypy` cache results for efficiency.

  1. Improved `–declaration` File Emitting

TypeScript 3.5 made improvements to `.d.ts` file generation, providing more accurate type declarations for library consumers, and addressing scenarios where types could be incorrectly emitted or omitted.

This improvement is unique to TypeScript as it relates to its dual role as both a language and a tool for generating type declaration files for JavaScript. C#, Java, and Python have different mechanisms for interface definitions and type annotations.

  1. The `const` Assertions

TypeScript 3.

5 introduced `const` assertions, a way to signal that a literal object should be treated as read-only, with properties inferred as the most specific type possible (e.g., literal types for strings and numbers).

```typescript let x = { text: “hello” } as const; ```

JavaScript's `const` keyword provides immutability but doesn't infer types. C# readonly members, Java's final, and Python's `Final` from `typing` offer related functionality but with differences in mutability and type inference.

  1. Conclusion

TypeScript 3.5 continued TypeScript's trend of enhancing its type system, improving developer productivity through better tooling, and optimizing compiler performance. By introducing features like the `Omit` type, smarter union type checking, and `const` assertions, TypeScript 3.5 helps developers write safer and more maintainable code. Comparing these features to those in C#, Java, and Python highlights TypeScript's unique position in providing a statically typed experience on top of JavaScript, combining the best of both static and dynamic typing worlds for web development.


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.


typescript_3.5.txt · Last modified: 2024/04/28 03:13 by 127.0.0.1