- Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
🔍 Search Terms
import defer
✅ Viability Checklist
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ 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 nandimport * as nhave the same type. import defershould 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 parseimport defer{... }andimport defer fooand give proper diagnostics, rather than relying on the existing parsing recovery for invalid syntax (that would parseimport defer{x } from "y"asimport 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
a-tarasyuk, ah-yu, robpalme, tonywu6, petamoriken and 2 more
Metadata
Metadata
Assignees
Labels
CommittedThe team has roadmapped this issueThe team has roadmapped this issueSuggestionAn idea for TypeScriptAn idea for TypeScript