Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get angular2 to work in eclipse with typescript

So I was starting researching about angular2 and since I saw so many references to typescript being prefered I am trying to switch to it from javascript. Problem is, I saw a nice little guide I could follow to install it all in eclipse (angular, javascript, everything needed to launch the 5 minute guide code on the main page of angular), so I did it and managed to get it to work.

Now I would like to do the same with typescript, but I find myself lost since it doesn't seem to be working, I can't launch code, it's like node.js isn't working anymore, but since I do not know what the expected result is, I am not sure what is missing.

For example, I re did the 5 minute guide and notice as a difference that I do not have the installation of the modules, nor any run-as configuration ready, in fact, I can't manage to run as any typescript code I try to do.

like image 977
monkey intern Avatar asked Mar 09 '16 11:03

monkey intern


People also ask

Can we use TypeScript in Eclipse?

CodeMix is an Eclipse plugin that delivers exceptional support for TypeScript in Eclipse, and gives you the ability to add Code-compatible extensions directly into Eclipse to further enhance your TypeScript coding experience.

How run ng serve in Eclipse?

If you choose to start the server, go to the "Servers" view and expand Angular CLI. Select the project in question and click the "Start" button. A new tab will open in the Terminal+ view running "ng serve".

Can you use Angular with TypeScript?

Angular is a modern framework built entirely in TypeScript, and as a result, using TypeScript with Angular provides a seamless experience. The Angular documentation not only supports TypeScript as a first-class citizen, but uses it as its primary language.


3 Answers

What I did was:

1- Install Eclipse Mars, other guys uses older versions

2- Install Node.js

3- Install WildFly Server

4- Install TypeScript plugin https://marketplace.eclipse.org/content/typescript

5- Import my project in eclipse, you may have to create a new static web project and add your files in there. The 5 minute quick start is not an eclipse web project so you may not be able to import this. Do not forget to copy and past the same structure with the node modules that you have

6- Right click on the project > Configure > Enable Typescript Builder

7- Right Click the project > Properties > TypeScript > Compiler and configure as follows:

enter image description here

I hope this will do it for you.

Remember, this plugin does not respect json configuration file, so you have to do this manually as in the screenshot. Also, if you are going to provide arguments to your component constructor, You will have errors. Let me know if you got those. Another thing to mention is that using some annotations like @Input will not work, you will have to use inputs:[] inside your @Component annotation.

like image 97
Mohy Eldeen Avatar answered Oct 10 '22 04:10

Mohy Eldeen


You can try to add those plugins on top of Mars:

  • https://github.com/angelozerr/angular2-eclipse
  • https://github.com/angelozerr/typescript.java

Those 2 are incubating but already provide good features. There is another one, that I didn't try but which has some popularity:

  • https://github.com/palantir/eclipse-typescript
like image 25
Mickael Avatar answered Oct 10 '22 03:10

Mickael


Eclipse >= Neon

  • sudo npm install -g angular-cli (ng help must work)
  • See: https://github.com/angelozerr/angular2-eclipse
  • Install it and restart Eclipse
  • Open a .ts file
like image 1
Christophe Roussy Avatar answered Oct 10 '22 05:10

Christophe Roussy