Skip to content

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

Closed

Description

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};

Activity

  1. tinganho commented on May 12, 2015

    @tinganho
    Contributor

    I would love to have this!

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

  2. Piedone commented on May 12, 2015

    @Piedone

    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#.

  3. AbubakerB commented on May 12, 2015

    @AbubakerB
    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?

  4. tinganho commented on May 12, 2015

    @tinganho
    Contributor

    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.

  5. AbubakerB commented on May 12, 2015

    @AbubakerB
    Contributor

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

  6. Piedone commented on May 12, 2015

    @Piedone

    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?

  7. ahejlsberg commented on May 12, 2015

    @ahejlsberg
    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.

  8. danquirk commented on May 12, 2015

    @danquirk
    Member
  9. locked and limited conversation to collaborators on Jun 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    DuplicateAn existing issue was already createdOut of ScopeThis idea sits outside of the TypeScript language design constraintsSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions