Visitar URL original
Select content mapper at import level thanks to the `with` keyword Β· Issue #65404 Β· microsoft/TypeScript Β· GitHub
Skip to content

Select content mapper at import level thanks to the with keywordΒ #65404

Open

Description

πŸ” Search Terms

content mappers

βœ… Viability Checklist

⭐ Suggestion

Extensions filter are too limitative for content mappers. I think that we should be able to use with keyword when importing module to select the right content mapper.

πŸ“ƒ Motivating Example

For example, with this content mapper : https://github.com/nfroidure/json-schema-content-mapper I have to import .jsonchema files but what I would like to do is to import schemas by URLs and I cannot change their extension.

Something like:

import type Alert from "https://schemas.sourcemeta.com/nasa/gcn/v4.2.0/notices/core/alert.json" with { type: "jsonschema" };

would be cool.

πŸ’» Use Cases

  1. What do you want to use this for?
    To be able to use URLs to import modules since we cannot change extensions of it
  2. What shortcomings exist with current approaches?
    Copy URL content locally with the right extension.
  3. What workarounds are you using in the meantime?
    None atm, no real use since TS7.1 is still in beta, just experiments.

Activity

  1. nfroidure commented on Nov 9, 2026

    @nfroidure
    Author

    Just noticed that turbopack whaere just using its own props ( https://nextjs.org/docs/app/api-reference/config/next-config-js/turbopack#inline-loader-configuration-with-import-attributes ), so maybe better to add as tsContentMapper one.

    import type Alert from "https://schemas.sourcemeta.com/nasa/gcn/v4.2.0/notices/core/alert.json"
      with { tsContentMapper: "json-schema-content-mapper" };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    SuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions