bmeck / proposal-from-import

AKA: make code completion work.
MIT License
80 stars 0 forks source link

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.

from "foo" import {bar};

Explanation

Status Quo

import /*code completion here*/

Could be a string for the module specier, or the list of imported binding.

import "foo"/*code completion/programmer moves caret here after typing*/
   // ^ code completion caret needs to be here for binding names

Proposed

from /*code completion here*/

Module specifiers are the only thing that could be here to allow better code completion.

Imports without bindings

import "a";

Just for posterity we can add the from prefixed form, even though it is more verbose:

from "a" import;

Working with other proposals

Module attributes

The position of module attributes would still be at the end.

from "./foo.json" import foo with type="json"

Concerns

// 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:

from [no LineTerminator here] ModuleSpecifier import ImportClause?