from './foo' import './foo';

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

from './foo' import './foo';

Cyril Auburtin
Could 
```js
from 'name' import something;
```

be added to ES module grammar?

which would work like the current
```js
import something from 'name';
```

The advantage is to sort more easily import, and have autocompletion of imported identifiers


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: from './foo' import './foo';

Michael J. Ryan
Personally I like this syntax better, but feel that changing or adding import syntax at this point I'd a non-starter...  Not sure what others feel about this one.

On Wed, Apr 4, 2018, 09:23 Cyril Auburtin <[hidden email]> wrote:
Could 
```js
from 'name' import something;
```

be added to ES module grammar?

which would work like the current
```js
import something from 'name';
```

The advantage is to sort more easily import, and have autocompletion of imported identifiers

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: from './foo' import './foo';

Vladimir Vapirov
In reply to this post by Cyril Auburtin
I had the same idea coming from Python to JS. Current import syntax doesn’t allow IDE’s to hint which functions/modules are available for import.

Please see my proposal and let me know your thoughts


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: from './foo' import './foo';

Bob Myers
You're seriously underestimating how smart IDEs are or can be.

Some IDEs are already suggesting the entire import statement when a symbol is used, based on what's in other modules, package.json, etc.
There's no reason why an IDE can't auto-suggest the import name based on undefined symbols in the file, among other things.
There's also no compelling reason why you can't type `import {} from "module";`, then go back and fill in the symbol name inside the `{}`.
You could use a snippet manager to make this semi-painless, defining the snippet as something like `import {$2} from "$1";`.

Bob

On Tue, Apr 10, 2018 at 8:48 AM, Vladimir Vapirov <[hidden email]> wrote:
I had the same idea coming from Python to JS. Current import syntax doesn’t allow IDE’s to hint which functions/modules are available for import.

Please see my proposal and let me know your thoughts


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss



_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Re: from './foo' import './foo';

Isiah Meadows-2
I already use a similar snippet for `const foo = require("bar")`,
since not all module names are valid identifiers (think: anything with
a hyphen), and sometimes I prefer to destructure. In Atom, I currently
have a snippet for `const ${2:$1} = require("$1")` and `import ${2:$1}
from "$1"` that I personally use\*, which are incredibly useful (I
don't have to specify whether I'm using named, default, or namespace
imports, and can just type them as I go, and I also get a helpful
default name in the process).

\* Well...not currently, thanks to this ugly bug in a recent update:
https://github.com/atom/snippets/issues/266

-----

Isiah Meadows
[hidden email]

Looking for web consulting? Or a new website?
Send me an email and we can get started.
www.isiahmeadows.com


On Mon, Apr 9, 2018 at 11:46 PM, Bob Myers <[hidden email]> wrote:

> You're seriously underestimating how smart IDEs are or can be.
>
> Some IDEs are already suggesting the entire import statement when a symbol
> is used, based on what's in other modules, package.json, etc.
> There's no reason why an IDE can't auto-suggest the import name based on
> undefined symbols in the file, among other things.
> There's also no compelling reason why you can't type `import {} from
> "module";`, then go back and fill in the symbol name inside the `{}`.
> You could use a snippet manager to make this semi-painless, defining the
> snippet as something like `import {$2} from "$1";`.
>
> Bob
>
> On Tue, Apr 10, 2018 at 8:48 AM, Vladimir Vapirov
> <[hidden email]> wrote:
>>
>> I had the same idea coming from Python to JS. Current import syntax
>> doesn’t allow IDE’s to hint which functions/modules are available for
>> import.
>>
>> Please see my proposal and let me know your thoughts
>>
>> https://github.com/vladi-dev/proposal-reverse-import-syntax
>>
>> _______________________________________________
>> es-discuss mailing list
>> [hidden email]
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
>
> _______________________________________________
> es-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es-discuss
>
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss