Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import defer Stage 2.7 proposal support #59391

Open
6 tasks done
nicolo-ribaudo opened this issue Jul 22, 2024 · 0 comments Β· May be fixed by #60757
Open
6 tasks done

import defer Stage 2.7 proposal support #59391

nicolo-ribaudo opened this issue Jul 22, 2024 · 0 comments Β· May be fixed by #60757
Assignees
Labels
Committed The team has roadmapped this issue Suggestion An idea for TypeScript

Comments

@nicolo-ribaudo
Copy link

πŸ” 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 @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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Committed The team has roadmapped this issue Suggestion An idea for TypeScript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants