You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suggestion: reversed syntax for importing symbols from a module #3127
Yes! Had the same thought during Anders Hejlsberg (@ahejlsberg) 's Build talk. It's practically the same rationale than for the reversed LINQ syntax in C#.
I think everyone would love that! I'm sure even the TS team (i think Anders even pointed it out during the build talk), but the design goals of TS is to follow the ES specs as much as possible (it makes everything so much easier for them -- and us) [Spec-Goal-6]. If it wasn't for that rule, im sure 100s of things would be different, but it's that goal (and others) that makes it oh so very awesome!
One thing that could be suggested is that we could type it as
from"whatever"import{Something};
and it get generated as
import{Something}from"whatever";
but at the same time also support the ES6 spec of typing import first then from second...., but that's too cumbersome and not worth it i guess.
Another suggestion could be to create a VS snippet for typescript so that when you type "import[TabKey]" the following line is emitted with the cursor ($c) inside the from "", as follows:
Abubaker Bashir (@AbubakerB) that would be a very good solution to this problem. I think those who sit in TC39 should have thought about this problem. 😠 Because we have to live with this the rest of our lives now.
Good point about ES compatibility... Indeed, it would be a limited but for part of the audience still awesome thing to at least add better support in tooling to make the experience like it would be with the reversed syntax. And if this could be built directly into the TS compiler maybe this tooling support could be accessible for other editor plugins easily?
Much as it would be nice to have from come before import this is already a done deal and alignment with ES6 trumps here. However, I agree it would be nice to have snippet support so you could easily tab between the fields.
Activity
tinganho commentedon May 12, 2015
I would love to have this!
(I don't care if its break ES6 module syntax)
Piedone commentedon May 12, 2015
Yes! Had the same thought during Anders Hejlsberg (@ahejlsberg) 's Build talk. It's practically the same rationale than for the reversed LINQ syntax in C#.
AbubakerB commentedon May 12, 2015
I think everyone would love that! I'm sure even the TS team (i think Anders even pointed it out during the build talk), but the design goals of TS is to follow the ES specs as much as possible (it makes everything so much easier for them -- and us) [Spec-Goal-6]. If it wasn't for that rule, im sure 100s of things would be different, but it's that goal (and others) that makes it oh so very awesome!
One thing that could be suggested is that we could type it as
and it get generated as
but at the same time also support the ES6 spec of typing
importfirst thenfromsecond...., but that's too cumbersome and not worth it i guess.Another suggestion could be to create a VS snippet for typescript so that when you type
"import[TabKey]"the following line is emitted with the cursor ($c) inside thefrom "", as follows:then another tab would take you within the {}
.... maybe?
tinganho commentedon May 12, 2015
Abubaker Bashir (@AbubakerB) that would be a very good solution to this problem. I think those who sit in TC39 should have thought about this problem. 😠 Because we have to live with this the rest of our lives now.
AbubakerB commentedon May 12, 2015
Tingan Ho (@tinganho) yea, but I'm sure they had their reasons though (or maybe they just did it for the laughs!)
Piedone commentedon May 12, 2015
Good point about ES compatibility... Indeed, it would be a limited but for part of the audience still awesome thing to at least add better support in tooling to make the experience like it would be with the reversed syntax. And if this could be built directly into the TS compiler maybe this tooling support could be accessible for other editor plugins easily?
ahejlsberg commentedon May 12, 2015
Much as it would be nice to have
fromcome beforeimportthis is already a done deal and alignment with ES6 trumps here. However, I agree it would be nice to have snippet support so you could easily tab between the fields.danquirk commentedon May 12, 2015
Also see:
#2370 (comment)
#2371 (comment)