User Tools

Site Tools


typescript_2.9

TypeScript 2.9

Return to TypeScript Version History, TypeScript, JavaScript


TypeScript 2.9, released in May 2018, introduced several enhancements and new features to improve the language's flexibility, developer experience, and its ability to model JavaScript patterns more accurately. This version focused on broadening the type system and tooling capabilities, addressing common pain points, and further aligning with ECMAScript standards. Below is an overview of the main features and improvements introduced in TypeScript 2.9, complete with code examples and comparisons to similar features in other programming languages, along with 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. Import Types

TypeScript 2.9 introduced the ability to import types using the `import()` syntax within a type annotation. This feature allows for dynamically loading types, which is particularly useful for code splitting and working with dynamic module loading scenarios.

```typescript type MyType = import(“./myModule”).MyType; ```

JavaScript does not have a type system, so this is specific to TypeScript. C# supports dynamic type loading through reflection (e.g., `Assembly.Load`). Java can dynamically load classes with `Class.forName()`. Python uses dynamic imports with the `importlib` module, but these are runtime features rather than type system features.

  1. Support for `Symbol` and `Symbol` Properties

TypeScript 2.9 improved support for ES2015 `Symbol` and properties keyed by symbols, allowing developers to use `Symbol` as a first-class type and declare symbol properties in interfaces.

```typescript const mySymbol = Symbol(); interface MyInterface {

 [mySymbol]: string;
} ```

JavaScript introduced `Symbol` in ES2015 as a way to create unique property keys. C# has no direct equivalent to `Symbol`, but attributes can be used for some similar metadata scenarios. Java uses annotations for similar metadata purposes. Python's dynamic nature allows all kinds of keys in dictionaries, but it doesn't have a direct `Symbol` equivalent.

  1. Support for Numeric Separators

TypeScript 2.9 added support for numeric separators, aligning with the ECMAScript proposal, which improves readability for numeric literals by allowing underscores as separators.

```typescript let billion = 1_000_000_000; ```

JavaScript added numeric separators in ES2021. C# supports numeric separators in the form of digit separators (`_`). Java introduced numeric separators in Java 7 using underscores. Python also supports numeric literals with underscores for readability from version 3.6.

  1. `–resolveJsonModule` Flag

The `–resolveJsonModule` flag in TypeScript 2.9 allows for importing `.json` files directly in TypeScript files, enabling type checking and intellisense for JSON data.

```typescript import * as data from “./data.json”; ```

JavaScript modules can import JSON files natively in modern environments. C#, Java, and Python do not support importing JSON files directly as modules but can read and parse JSON data through standard library functions or third-party libraries.

  1. `keyof` and Lookup Types with Intersection Types

TypeScript 2.9 improved the `keyof` operator and lookup types to work more effectively with intersection types, enhancing the language's capability to query and manipulate property keys.

```typescript type A = { a: string }; type B = { b: number }; type ABKeys = keyof (A & B); // “a” | “b” ```

JavaScript does not have a type system, so `keyof` is TypeScript-specific. C#'s and Java's reflection APIs can be used to inspect types, but they do not offer a direct equivalent to TypeScript's `keyof`. Python's dynamic nature allows for inspection of object attributes at runtime, but it lacks a compile-time `keyof` equivalent.

  1. Improved Inference for Generics

TypeScript 2.9 made improvements to the inference of generics, allowing for more precise and flexible modeling of functions and types that operate over other types, reducing the need for explicit type annotations.

```typescript function getProp<T, K extends keyof T>(obj: T, key: K) {

 return obj[key];
} ```

C#'s and Java's type systems also support generics with constraints, offering similar capabilities for type-safe code reuse. Python's typing extensions introduced generics in PEP 484, allowing for type annotations that can specify type variables.

  1. `–declarationMap` Source Mapping

The `–declarationMap` flag introduced in TypeScript 2.9 allows developers to generate source maps for `.d.ts` declaration files, improving the debugging experience for TypeScript libraries.

This feature is unique to TypeScript's tooling. C#, Java, and Python offer various forms of debugging support and source mapping through their tool

chains, but TypeScript's declaration maps are specific to its ecosystem.

  1. Conclusion

TypeScript 2.9 continued to refine the language with features aimed at improving developer productivity, code maintainability, and the overall flexibility of the type system. By introducing import types, enhanced support for `Symbol`, numeric separators, and improved generics inference, TypeScript 2.9 offers tools that cater to modern development patterns, further cementing its role as a key superset of JavaScript. Comparing these features with those in C#, Java, and Python highlights TypeScript's unique approach to blending dynamic JavaScript patterns with the safety and robustness of a statically typed language, making it an invaluable tool 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_2.9.txt · Last modified: 2024/04/28 03:13 (external edit)