Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: reversed syntax for importing symbols from a module #3127

Closed
BenedekFarkas opened this issue May 12, 2015 · 8 comments
Closed

Suggestion: reversed syntax for importing symbols from a module #3127

BenedekFarkas opened this issue May 12, 2015 · 8 comments
Labels
Duplicate An existing issue was already created Out of Scope This idea sits outside of the TypeScript language design constraints Suggestion An idea for TypeScript

Comments

@BenedekFarkas
Copy link

So instead of having to type:

import {} from "whatever";

and then go back to fill in the {} with IntelliSense, a LINQ-like syntax would be easier to use like this:

from "whatever" import {Something};
@tinganho
Copy link
Contributor

I would love to have this!

(I don't care if its break ES6 module syntax)

@Piedone
Copy link

Piedone commented May 12, 2015

Yes! Had the same thought during @ahejlsberg 's Build talk. It's practically the same rationale than for the reversed LINQ syntax in C#.

@AbubakerB
Copy link
Contributor

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:

import {} from "$c" ;

then another tab would take you within the {}

.... maybe?

@tinganho
Copy link
Contributor

@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
Copy link
Contributor

@tinganho yea, but I'm sure they had their reasons though (or maybe they just did it for the laughs!)

@Piedone
Copy link

Piedone commented 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
Copy link
Member

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.

@ahejlsberg ahejlsberg added Suggestion An idea for TypeScript Out of Scope This idea sits outside of the TypeScript language design constraints labels May 12, 2015
@danquirk
Copy link
Member

Also see:
#2370 (comment)
#2371 (comment)

@danquirk danquirk added the Duplicate An existing issue was already created label May 12, 2015
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created Out of Scope This idea sits outside of the TypeScript language design constraints Suggestion An idea for TypeScript
Projects
None yet
Development

No branches or pull requests

6 participants