Skip to content

import defer Stage 3 proposal support #59391

Description

🔍 Search Terms

import defer

✅ Viability Checklist

⭐ Suggestion

We are working towards a PR implementing the https://github.com/tc39/proposal-defer-import-eval/ proposal, to have TypeScript support ready once the proposal reaches Stage 3. For this proposal I think it should behave as follows:

  • This features does not affect type checking, as import defer * as n and import * as n have the same type.
  • import defer should only be allowed when targeting ESNext modules, as it's not possible to compile it to older ES versions.
  • Even though the proposal only supports import defer * as n, we should still parse import defer { ... } and import defer foo and give proper diagnostics, rather than relying on the existing parsing recovery for invalid syntax (that would parse import defer { x } from "y" as import defer = <ident>; { x }; from; "y"

When talking about this with Daniel Rosenwasser (@DanielRosenwasser), he mentioned tsserver support. What would tsserver support look like for a feature like this one? I was thinking maybe a "Convert to deferred namespace import" refactor similarly to how we have a "Convert named imports to namespace import" refactor, but:

  • is this something that the TS team prefers to have in the initial implementation or separately?
  • am I missing something else that is obvious when it comes to tsserver support?

📃 Motivating Example

/

💻 Use Cases

Implementation of a TC39 proposal

Activity

  1. robpalme commented on May 1, 2025

    @robpalme

    The import defer proposal advanced to Stage 3 in Feb 2025, so the title of this issue should be updated Nicolò Ribaudo (@nicolo-ribaudo)

  2. changed the title [-]`import defer` Stage 2.7 proposal support[/-] [+]`import defer` Stage 3 proposal support[/+] on May 1, 2025
  3. nicolo-ribaudo commented on May 1, 2025

    @nicolo-ribaudo
    ContributorAuthor

    Question for the TS team: with the go rewrite, how do contributions work? Do I need two PRs, or just one? To which code base?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

CommittedThe team has roadmapped this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions