What the beta adds
But a major issue is that runtime environments may support different import attributes entirely, and may act differently depending on whether they’re present. [1]
That’s why TypeScript 7.1 introduces support for import attributes in ambient module declarations. [2]
What it does not check
Note that imports matching these declarations are not validated against files on disk. [3]
As is currently the behavior when an import matches an ambient module declaration, failed lookups will be reported at runtime or during a bundler’s build process. [4]
We recommend libraries not include them in their published packages, and end-users will need to declare them in their own projects if necessary. [5]
Source imports and the new API
You must have an appropriate --module setting (i.e. esnext, nodenext, or preserve) to use source imports, as well as the appropriate esnext option in --lib or --target. [6]
When using import source, every imported module has the type AbstractModuleSource, a new global type in lib.esnext.d.ts. [7]
TypeScript 7.1 ships a new API that allows building powerful tools and utilities using our syntactic and semantic analyses. [8]
Rather than exposing a monolithic API, TypeScript 7.1 is organized into several entry points, each serving a specific purpose. [9]
Sources
- The TypeScript source says: But a major issue is that runtime environments may support different import attributes entirely, and may act differently depending on whether they’re present. Announcing TypeScript 7.1 Beta
- The TypeScript source says: That’s why TypeScript 7.1 introduces support for import attributes in ambient module declarations. Announcing TypeScript 7.1 Beta
- The TypeScript source says: Note that imports matching these declarations are not validated against files on disk. Announcing TypeScript 7.1 Beta
- The TypeScript source says: As is currently the behavior when an import matches an ambient module declaration, failed lookups will be reported at runtime or during a bundler’s build process. Announcing TypeScript 7.1 Beta
- The TypeScript source says: We recommend libraries not include them in their published packages, and end-users will need to declare them in their own projects if necessary. Announcing TypeScript 7.1 Beta
- The TypeScript source says: You must have an appropriate --module setting (i.e. esnext, nodenext, or preserve) to use source imports, as well as the appropriate esnext option in --lib or --target. Announcing TypeScript 7.1 Beta
- The TypeScript source says: When using import source, every imported module has the type AbstractModuleSource, a new global type in lib.esnext.d.ts. Announcing TypeScript 7.1 Beta
- The TypeScript source says: TypeScript 7.1 ships a new API that allows building powerful tools and utilities using our syntactic and semantic analyses. Announcing TypeScript 7.1 Beta
- The TypeScript source says: Rather than exposing a monolithic API, TypeScript 7.1 is organized into several entry points, each serving a specific purpose. Announcing TypeScript 7.1 Beta