-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Request for alternative import syntax to improve auto-complete experience #2371
Comments
You're right that this is an awkward piece of syntax for tooling, but new alternate syntax is not the solution you want here. There is a simple and easy solution that doesn't require altering the language and diverging from ES6 syntax though: code snippets. It would look sort of like this: When you type 'imp' you should get a completion that is a snippet for the right import syntax. After committing the snippet (via enter, tab, space, etc) the cursor should be placed on the RHS to type the actual module name. After committing that text (via enter or tab) the cursor jumps back to the import names where you now can get completion suggestions since the module name has been written. |
This is a good example of the difference between the developer mindset and The developer comes up with a technology solution that assists the user in The designer aims to adapt the technology to the natural processes of the In this case the target users are themselves developers, so you might think I'm sure we could debate this until we are old and grey, but consider the I'll add the disclaimer that I've spent my entire career as a designer who Take my opinions with as many grains of salt necessary. It's my intention On Monday, March 16, 2015, Dan Quirk notifications@github.com wrote:
Greg Dorval
https://plus.google.com/+GregDorval https://twitter.com/gregdorval https://twitter.com/gregdorval https://plus.google.com/+GregDorval/posts |
We, and especially I, most definitely take the user experience seriously. You'll find more than a few comments from me throughout our issue tracker on where we're failing on that front (whether in the language itself or in the tooling) and what must be fixed. In this case you're simply not understanding the true costs and trade offs of the two proposed solutions. We cannot change the ES6 module syntax, that ship has sailed, it is not under our control, we can only provide another piece of input to the larger committee (which we have/did/do). We have to accept that the majority of future JavaScript brought to TypeScript will use this syntax that you do not like (for the record, I do not like it either, it clearly was designed without prioritizing the tooling related featured). So even if we take your proposed solution, the majority of people will not be able to benefit from it because they have tons of existing code that uses the JavaScript style and will want to remain consistent. On the other hand, by introducing our own syntax we risk future incompatibilities with JavaScript if they ever do change/augment their syntax, we require JavaScript developers to learn a new syntax, and we diverge further from JavaScript. This actually makes the user experience worse by having two pieces of different syntax that do identical things (particularly the initial on boarding experience for new TypeScript users), which is precisely why most languages try to avoid doing that sort of thing. We very rarely alter expression level syntax like you're proposing, and that's for good reasons, not because we don't prioritize the quality of the user experience. TypeScript is intended to be a typed superset of JavaScript. If we repeatedly alter expression level syntax for relatively minor gains then we will fail to maintain that design and end up with a very different language that simply compiles to JavaScript. The proposal I've shown above is exactly the type of UX developers are used to in a variety of different IDEs in order to speed up writing out boilerplate code. Snippets like this have been a frequently requested feature in TypeScript specifically since we didn't support them as well as other Visual Studio languages and other editors. We are not an iPhone app. We cannot simply make changes and break that functionality later if we decide we don't like it. Likewise any change we make today risks making any future designs harder for ourselves if we use up the valuable, limited design space that syntax and semantics affords us. The language decisions we make we live with forever and impact our future decisions forever. Yes, in an ideal world the ES6 syntax would be closer to what you're proposing and autocomplete would 'just work' without any extra tooling support. In reality we have to work with what's there and the snippet experience I showed above is a pretty solid solution that you'll find is actually quite natural and does not require any significant change in workflow or mental model. |
See also #2370 for discussions of how no one really likes the ES6 module import/export syntax. It's frustrating for us, too. The whole problem of how syntax influences tooling is one the team is intimately aware of -- one reason C# LINQ syntax moved the |
I completely understand that we don't operate in an ideal world where we So let me take this opportunity to commend the TypeScript team for making My comments may come across as harsh or abrasive but please know that I am I'd rather be part of the solution than the guy standing on the sideline Greg Dorval
https://plus.google.com/+GregDorval https://twitter.com/gregdorval https://twitter.com/gregdorval https://plus.google.com/+GregDorval/posts On 17 March 2015 at 11:09, Ryan Cavanaugh notifications@github.com wrote:
|
I don't know where it currently lies in our scheduled work but it is definitely not forgotten about. The import one in particular was the first thing I thought about when shown a demo of typing the ES6 module syntax. |
It would be nicer to have it sooner than later - especially as people start converting from the legacy import statements to the new syntax. |
Consider the following import statement:
With auto-suggest I need to start this by typing:
Then I can go back inside the {} and get auto-suggestions.
It would be very nice if TypeScript supported an alternate syntax for the same expression that was more conducive to auto-complete features.
For example:
This doesn't introduce any confusion or ambiguity about the meaning of the expression, either to the transpiler or the human reader, yet it provides a time-saving experience to the author when taking advantage of auto-complete features. I can now simply type the expression naturally from left to right, and get auto-suggestions/completions for both the from '...' and {}.
There are other cases where an alternate syntax would be beneficial. I will update this issue as I compile a list. Hopefully others will comment with suggestions as well.
The text was updated successfully, but these errors were encountered: