Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bmeck/proposal-from-import
AKA: make code completion work.
https://github.com/bmeck/proposal-from-import
Last synced: 7 days ago
JSON representation
AKA: make code completion work.
- Host: GitHub
- URL: https://github.com/bmeck/proposal-from-import
- Owner: bmeck
- License: mit
- Created: 2020-04-03T14:25:10.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-04-03T16:13:59.000Z (almost 5 years ago)
- Last Synced: 2025-01-17T22:59:39.015Z (about 1 month ago)
- Language: HTML
- Size: 26.4 KB
- Stars: 80
- Watchers: 9
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# from ... import ...;
**Champion**: Bradley Farias (@bmeck)
**Stage**: 0
Code completion is painful for the current order of `import` and `from`.
This proposal seeks to add the inverse to make code completion work.```mjs
from "foo" import {bar};
```## Explanation
### Status Quo
```mjs
import /*code completion here*/
```Could be a string for the module specier, or the list of imported binding.
* Tools cannot statically determine the list of possible bindings without the specifier, but it hasn't been added to the code yet.
* Tools can create a good completion by inserting the specifier, but doing so means a programmer needs to reposition the cursor to insert binding names which is the common case of imports.```mjs
import "foo"/*code completion/programmer moves caret here after typing*/
// ^ code completion caret needs to be here for binding names
```### Proposed
```mjs
from /*code completion here*/
```Module specifiers are the only thing that could be here to allow better code completion.
### Imports without bindings
```mjs
import "a";
```Just for posterity we can add the `from` prefixed form, even though it is more verbose:
```mjs
from "a" import;
```## Working with other proposals
### Module attributes
The position of module attributes would still be at the end.
```mjs
from "./foo.json" import foo with type="json"
```## Concerns
* We would be growing the grammar without any new semantics added to the language.
* We would need to have different `[no LineTerminator here]` rules in this form of import.```mjs
// allowed currently
import
* as foo
from
'foo';
```Due to `from` needing to be a contextual keyword it needs to avoid problems with ASI and would have a grammar like:
```mjs
from [no LineTerminator here] ModuleSpecifier import ImportClause?
```