User Tools

Site Tools


typescript_3.1

TypeScript 3.1

Return to TypeScript Version History, TypeScript, JavaScript


TypeScript 3.1, released in September 2018, introduced several key features aimed at enhancing the developer experience, improving the language's type-checking capabilities, and streamlining the development process for large-scale applications. This version focused on incremental improvements that further solidified TypeScript's position as a powerful tool for building robust web applications. Below is a summary of the main features and improvements in TypeScript 3.1, including code examples, comparisons to similar features in other programming languages, and links to essential TypeScript resources.

- 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. Mapped Types on Tuples and Arrays

TypeScript 3.1 extended mapped types to support tuples and arrays, enabling developers to create mapped types that transform the types of tuple and array elements.

```typescript type StringArray = string[]; type UppercasedStringArray = { [K in keyof StringArray]: Uppercase<StringArray[K]> }; ```

JavaScript does not have a type system, so this feature is specific to TypeScript. C# has similar capabilities with generics and LINQ. Java's streams can perform transformations on arrays and lists, but not at the type level. Python's type hints in PEP 484 do not support this kind of transformation.

  1. Properties Declarations on Functions

TypeScript 3.1 introduced the ability to declare properties on functions, enhancing support for patterns where functions also have properties attached to them.

```typescript function greet(name: string) {

 console.log("Hello, " + name);
} greet.someProperty = 42; ```

JavaScript functions can naturally have properties, but TypeScript 3.1 allows for type-safe declarations of these properties. C# delegates and Java methods cannot have properties in the same way. Python functions can have attributes assigned to them, but without static type checking.

  1. Version Selection with `typesVersions`

TypeScript 3.1 added support for the `typesVersions` field in `package.json`, allowing package authors to specify different type definitions for different TypeScript versions, improving library compatibility.

```json {

 "typesVersions": {
   "<3.1": { "*": ["ts3.0/*"] }
 }
} ```

This feature is unique to TypeScript's ecosystem. C#, Java, and Python manage library compatibility through different mechanisms, such as assembly versioning in C#, Maven or Gradle dependencies in Java, and package version specifications in Python's `pip`.

  1. Refactor from `require` to `import`

TypeScript 3.1 introduced a refactor to convert `require` statements into `import` statements, aligning with modern JavaScript module syntax and promoting best practices.

```typescript // Before refactor const express = require(“express”);

// After refactor import express from “express”; ```

JavaScript ES modules offer `import` and `export` syntax, which TypeScript encourages. C#, Java, and Python have their own module and package import systems, unrelated to TypeScript's ES module syntax.

  1. Improved UX for Project References

TypeScript 3.1 improved the user experience for project references, making it easier to manage and build projects with complex dependencies.

This improvement is specific to TypeScript's project management features. C#, Java, and Python have their own systems for managing project references and dependencies, such as `.csproj` files in C#, `pom.xml` or `build.gradle` files in Java, and `requirements.txt` or `Pipfile` in Python.

  1. Conclusion

TypeScript 3.1 continued TypeScript's trajectory of providing powerful tools for developers to write type-safe and maintainable JavaScript code. By introducing features like mapped types on tuples and arrays, property declarations on functions, and improved project reference management, TypeScript 3.1 enhances the language's versatility and developer productivity. Comparing these features with those available in C#, Java, and Python highlights TypeScript's unique approach to integrating static typing with JavaScript's dynamic nature, offering a compelling solution for developing complex web applications.


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.1.txt · Last modified: 2024/04/28 03:13 (external edit)