20

Closed

Support ES6 'import Foo from "bar"'

description

Hi!

The current draft supports the 'import Foo from "bar"' syntax which is a lot less verbose than the current TypeScript syntax for loading modules. It can be interpreted as:

import {Foo} = module('bar');

Which in an AMD module would be:

require(['bar'], function (bar) {
var Foo = bar.Foo;
});

Thanks!
Closed Jul 28 at 11:18 PM by jonturner
As part of our move to GitHub, we're closing our CodePlex suggestions and asking that people move them to the GitHub issue tracker for further discussion. Some feature requests may already be active on GitHub, so please make sure to look for an existing issue before filing a new one.

You can find our GitHub issue tracker here:
https://github.com/microsoft/typeScript/issues

comments

catfriend wrote Nov 27, 2012 at 5:28 PM

Also the following import variations:

import {Cat, Friend} from 'kittens'
import Cat from 'kittens'
import * from 'kittens'

module Kittens = 'kittens'
import Cat from Kittens.

catfriend wrote Nov 27, 2012 at 5:31 PM

And:

import {Cat: CatAlias} from 'kittens'

LukeH wrote Feb 19, 2013 at 5:55 PM

The module syntax in ES6 drafts has continued to change meaningfully over the last several months, so we are waiting for the proposal to stabilize before changing the TypeScript syntax. We will make this change as soon as there is strong consensus on module syntax in ES6 working group.

jonturner wrote Aug 2, 2013 at 5:17 PM

Moving this to resolved as you can now use import to reach into modules and pull out subcomponents.

jeffxpx wrote Oct 14, 2013 at 11:48 PM

I don't think this is resolved yet.

I checked the latest ES6 spec and it still has the "import ... from ..." syntax in it.

Can you give an example that uses import and compiles down to AMD syntax?

Here's an example of the import syntax I think you were referencing when you said you can use import to reach into modules and pull out subcomponents: http://bit.ly/18cESvg

However, this doesn't compile down to the AMD module syntax that the original poster wants it to compile down to.

Here's a simple example of what I think he wanted to accomplish. http://bit.ly/19JKKZi

How do we get the AMD syntax to happen?

MMiszy wrote Dec 16, 2013 at 11:07 PM

This issue is not resolved yet.