r/angularjs • u/tomastrajan • Mar 04 '16
Angular 2 code completion & auto imports completely blew my mind (with Typescript + IDEA)
6
u/vivainio Mar 04 '16
Looking forward to IDEs providing type checking in the html templates. I know ng guys are working on this...
1
-1
Mar 04 '16
Seems nice, but i'm still wondering why the hell i need to import anything when i would be much better off having a gulp-plugin (or whatever) do that for me when i'm going to be parsing the JS anyways
1
u/tomastrajan Mar 04 '16
The thing is it will not work in all cases, there might be name collisions (same class name, but from different module) where you have to as a developer explicitly chose which one to use (either by writing the import manually or by choosing from multiple options provided by code completion in your IDE). Because of that it's impossible to fully automate the process.
0
Mar 04 '16
If you have naming collisions, you should (be able to) fix that separately. Though like NPM i think that each module should be unique in its name anyways.
3
u/tomastrajan Mar 04 '16
Unique names are unreasonable requirement on class level. Then when I want to use
MyServiceclass which is implemented in two different npm packages. Code completion can't know which one I really want to use in that situation so I have to choose manually.-5
Mar 04 '16
So you don't find it annoying to do so much manual work for including stuff? Or know for a fact that people won't find a way around this?
This is one of the reasons i won't be going to Angular2 for some time. Things like this need to be dealt with in order to make the process as automated as possible. Not to mention that it isn't even faster than Angular 1 right now. And still will require many devs to make their plugins compatible. I never have to deal with this duplicated names with my current Angular projects. So why should i start to be bothered by it with Angular2 ?
6
u/tomastrajan Mar 04 '16
So let's see:
import / export syntax has nothing to do with angular or any other library for that matter is a property of language itself (both javascript and typescript)
as mentioned before, combination of typescript classes and npm packages produces this behavior which is work as intended so that multiple packages can contain classes with same name
this post is about the fact that you in fact DOESN'T have to write it yourself anymore because you have code completion
I suppose spending some time going more in depth on javascript language itself and maybe checking some other languages wouldn't hurt. SPOILER: vast majority of them exhibit some sort of import / export / dependency declaration mechanism
2
u/elgubbo Mar 04 '16
Thanks, i totally agree. It works the same way in any other language i know. Also i think it's more "standard" to use an import system that is compareable those of other languages instead of using yet another convoluted tool or script to have the same result.
-1
Mar 04 '16
Thats the problem. You know other languages, but aren't big in Javascript apparently. Nobody uses any tool at the moment for this shite
1
1
Mar 04 '16
So you're saying we can't magically use non-unique and non-namespaced objects from other libraries?? I thought programs could read minds...
-1
Mar 04 '16
So you are saying you have been having major issues with this already? Wow, thats amazing!
1
Mar 04 '16
I know the importing is about Ecmascript, but doesn't change the fact that i don't have to do that now. Especially in smaller projects.
This import-hell, uncommon to javascript but inherited from other languages from people who don't know Javascript and apparently don't want to learn it. Proper devs won't have any issues with dependencies or naming of modules.
0
Mar 04 '16
[deleted]
-1
Mar 04 '16
So you say that big projects are having a hard time with naming conventions and handle global scope. That is just plain bullshit. It fixes a problem amateur Javascript programmers have when switching languages. Not because big projects have issues.
2
u/Poltras Mar 04 '16
import * as ngCore from 'angular2/core';1
Mar 04 '16
I think its what i'm gonna do most of the time.
1
u/jmcunningham Mar 07 '16
I'm guessing you don't see the benefits of explicit dependencies?
1
Mar 07 '16
None whatsoever. I'm a lazy developer. Don't want to specify these things as 99% of the time i don't even have to anyways
1
2
u/[deleted] Mar 05 '16
This is something Webstorm and Eclipse have been doing forever.