This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 233197 - Support for TypeScript
Summary: Support for TypeScript
Status: CLOSED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 7.4
Hardware: PC All
: P1 normal with 67 votes (vote)
Assignee: Petr Pisl
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-22 16:16 UTC by Christian Lenz
Modified: 2020-06-13 21:49 UTC (History)
19 users (show)

See Also:
Issue Type: ENHANCEMENT
Exception Reporter: df


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Lenz 2013-07-22 16:16:59 UTC
I work since a few weeks with TypeScript and Visual Studio, but I want use Netbeans with git and TypeScript support. TypeScript would be great.


Regards

ChrisLE
Comment 1 yougo 2013-09-21 12:11:18 UTC
+1. But I work on Linux.
 
Seeing as Typescript's compiler is simply compiles
TypeScript (which is a superset of JavaScript) to JavaScript, 
I think a simple change to the current JSDT will suffice.
It need only detect that a file extension *.ts needs to be 
compiled to a *.js. 

One issue I see is that of installing the typescript compiler.
A first version will simply require a pre-installation. A future version
need only add the TypeScript compiler (pre-compiled to JavaScript)  
as a library within Netbeans. 

BTW, NetBeans JSDT is very good.
Keep up the excellent work. B-)
Comment 2 yougo 2013-09-21 20:07:44 UTC
(In reply to yougo from comment #1)
> +1. But I work on Linux.
>  
> Seeing as Typescript's compiler is simply compiles
> TypeScript (which is a superset of JavaScript) to JavaScript, 
> I think a simple change to the current JSDT will suffice.
> It need only detect that a file extension *.ts needs to be 
> compiled to a *.js. 
> 
> One issue I see is that of installing the typescript compiler.
> A first version will simply require a pre-installation. A future version
> need only add the TypeScript compiler (pre-compiled to JavaScript)  
> as a library within Netbeans. 
> 
> BTW, NetBeans JSDT is very good.
> Keep up the excellent work. B-)

Ooops... just realized that last paragraph may be misinterpreted.
When I say JSDT I am referring to the JS debugging tools. Specifically 
the Chrome plugin.
Comment 3 Christian Lenz 2013-09-22 07:32:26 UTC
I think its more than that. Not only the compiler, we need formatting support, auto completion, syntax highlighting yeah :).
Comment 4 yougo 2013-09-23 08:03:58 UTC
(In reply to ChrisLE from comment #3)
> I think its more than that. Not only the compiler, we need formatting
> support, auto completion, syntax highlighting yeah :).

Correct. But if you look at the compiler, it has a set of services
that already provide many of things you already need. Granted, 
one still requires to interface these services in JS to the Netbeans
Java stuff.

So I was looking at this also and figured that maybe one could:
1. Compile the Typescript compiler to JavaScript via itself
2. Compile the JavaScript to Java bytecode via Rhino
3. Extend the Web development stuff in NetBeans to access these java services

Specifically, I think that creating support for a new "ts" extension
and compiling the TS to another JS directory will suffice. The TS 
services would only work on these "*.ts" files.

Execution and debugging would be done on the JS source only.
Note however that the TS compiler also provides map files so
that one can debug the TS directly. But I don't think that is 
essential in a first version.

For an example one can look at the open source CATS IDE to see how these
services are used [0]. Their is also an Eclipse plug-in but I have not 
checked what their solution is. If they do use direct parsing, I think
extending the JS parser would require minimum work. In fact that is
already done. 
 
[0] https://github.com/jbaron/cats
[1] https://github.com/palantir/eclipse-typescript
Comment 5 bennyn 2013-12-11 22:39:30 UTC
It would be great to have TypeScript support in NetBeans! I've seen that it is already available in IntelliJ IDEA. Would be nice if NetBeans follows there!
Comment 6 jvilk 2014-04-08 15:35:01 UTC
There is also an Eclipse plugin for TypeScript under rapid development that integrates with the aforementioned compiler services:

https://github.com/palantir/eclipse-typescript

It would be really great if someone could step in and implement equivalent TypeScript support for NetBeans.
Comment 7 brickyenne 2014-06-18 22:06:16 UTC
Really like NetBeans for my day to day work and it would be really helpful to have Typescript support.
Comment 8 sgtgarcia 2014-10-26 21:46:13 UTC
Google has announced at ngEurope that Angular 2 is developped using AtScript, a superset of TypeScript. Typescript is gaining momentum and IMHO will be a "must have" in a couple of months.
Comment 9 Petr Pisl 2014-11-10 14:07:13 UTC
There is not time in the current dev time frame for adding full support. I can try to create some alpha version, but the first step is obtaining parser and lexer for this language in java. It someone has a pointer to that or ANTLR grammar, it would be great.
Comment 10 Petr Pisl 2014-11-10 14:07:30 UTC
There is not time in the current dev time frame for adding full support. I can try to create some alpha version, but the first step is obtaining parser and lexer for this language in java. It someone has a pointer to that or ANTLR grammar, it would be great.
Comment 11 bennyn 2014-11-12 12:17:51 UTC
@Petr Pisl: I am very happy to read that you would like to help bringing TypeScript support to NetBeans. An alpha version would be a huge step to kick this off! I have some contacts to the TypeScript team. Maybe I can setup a connection between you guys. Just tell what you need exactly. I will go and ask for an ANTLR grammar.
Comment 12 terje7601 2014-11-12 12:38:40 UTC
What about integrating the TypeScript compiler & let it do most of the work?

The compiler comes as an npm package, and the NetBeans dev builds have Node.js support now. The output of the compiler is also pretty parsable:
greeter.ts(12,10): error TS1005: ';' expected.
greeter.ts(12,35): error TS2345: Argument of type '{ firstname: string; }' is not assignable to parameter of type 'Person'.
So the compiler could provide NetBeans with a list of syntax/semantic errors, & then NetBeans could mark the errors in the editor.

And for syntax highlighting (that's the lexer I assume?), maybe it would be possible to re-use JavaScript syntax coloring, & simply add the TypeScript-specific keywords to the list of keywords?

Disclaimer: I'm no TypeScript nor NetBeans expert, so maybe this is an awful idea :)
Comment 13 Petr Pisl 2014-11-12 12:43:03 UTC
My wish would be a lexer or parser written in java, but I didn't find it:). The ANTLR grammar would be great. I can generate the parser from it. I know that the grammar is described in the documentation, but such things would speed up the work.

Regarding reusing compiler from node.js package. The compiler is able to provide AST, but the problem is that you need to run parser and lexer almost after every keystroke. It must be fast. If we want to reuse we need to run external process. I'm afraid about the performance. I will try to do some measurement.
Comment 14 bennyn 2014-11-12 12:47:52 UTC
Hey, thanks for joining the conversation! Your ideas sound logical. But I also don't know if this works as I never wrote a parser for a scripting language. But I found that there is something called a "typescript-service" for node which can format text: https://www.npmjs.org/package/typescript-services - There is also another guy who wrote something to access to the TypeScript Language Services: https://github.com/clausreinke/typescript-tools
Comment 15 bennyn 2014-11-12 12:54:34 UTC
P.S. I never worked with ANTLR grammar definitions but do they look like this? https://github.com/vandermore/Randori-Jackalope/tree/master/antlr4
Comment 16 Petr Pisl 2014-11-12 16:54:04 UTC
@bennyn: Yes, it is grammar for typescript. But the mentioned one is only part. From the author comment:

//          Only defining items related to Declaration Source Files
//          since I am only parsing '.d.ts' files.
Comment 17 tomcon 2015-02-12 16:05:19 UTC
Surely all that is needed initially - and would be very very useful - is simply a 'compile on save' feature for .ts files to .js files. This is used in some other products at the minute. i.e. similar interface for css preprocessors
Comment 18 vojtech.habarta 2015-03-06 09:44:39 UTC
Angular team announced that Angular 2 is based on TypeScript. They collaborated with TypeScript team and merged AtScript features (mainly annotations) into TypeScript.

So please make this a priority.

TypeScript comes with Language Service API (https://github.com/Microsoft/TypeScript/wiki/Using-the-Language-Service-API) which implements statement completions, signature help, code formatting and outlining, colorization, etc... So there is no need to implement grammar/parser in NetBeans. In fact I think it is a wrong way because language is complex and evolves. There is also "TS Server" pull request (https://github.com/Microsoft/TypeScript/pull/2041) which will further simplify editor integration (should be in TypeScript 1.5).
Comment 19 terje7601 2015-03-06 11:12:23 UTC
Maybe the nashorn team can help? They are working on TypeScript support & there is/will be a parser API for nashorn as well.
Comment 20 urbiwan 2015-03-10 21:56:11 UTC
As mentioned AngularJs2 will be based on Typescript would be awesome to see support for this in Netbeans asap. 

Netbeans one of the best IDE at the moment and I think after the announcement from google typescript is a must-have-feature.

Doesn't matter if typescript is full supported or not. A basic support ( code completion, syntax highlighting and compile on save ) would be ok.   

See http://blog.scottlogic.com/2015/01/20/typescript-compiler-api.html
Comment 21 tomcon 2015-03-10 22:29:43 UTC
> Surely all that is needed initially - and would be very very useful - 
> is simply a 'compile on save' feature for .ts files to .js files. 
> This is used in some other products at the minute. 
> i.e. similar interface for css preprocessors

Can someone please just look at the Typescript support in WebStorm?

It is a simple 'compile on save' feature with the .js output file shown under the .ts file node in the project tree.

That is all that is needed in the short term - maybe even longer term - please don't overcomplicate things and if you can deliver this relatively simple need it would be a big step forward. Other options can be developed but they will take too long and the software world needs the support now!

Thanks
Tom
Comment 22 roben 2015-03-11 08:58:27 UTC
I would rather have full editor capabilities with code completion, "go to declaration" and if possible some basic refactoring.

Compile on save can easily be archived with grunt/grunt-watch running in the background. This also is much more customizable than a quick and dirty integrated solution.
Comment 23 bennyn 2015-03-11 14:03:20 UTC
Hello, I am pleased to see that the discussion here was revived. I read on stackoverflow that TypeScript is a strict superset of ECMAScript 5, so you could extend any ECMAScript bnf with syntax definitions from the TypeScript specification. A starting point could be: http://www.antlr3.org/grammar/1153976512034/ecmascriptA3.g (Source: http://stackoverflow.com/a/14529028/451634).
Comment 24 urbiwan 2015-03-11 14:10:02 UTC
Why using a grammer, when typescript offers a nice way ( compiler api , language service api, ts server ( next release )  ) to integrate it into an existing IDE?

here is an example for the atom editor 
https://github.com/TypeStrong/atom-typescript
https://github.com/TypeStrong/atom-typescript/blob/6fbf860eaf971baa3aca939626db553898cb40db/lib/main/lang/projectService.ts#L58-L244
Comment 25 brickyenne 2015-03-11 14:12:19 UTC
As other have said, a lot of things can be done to bring TypeScript support to Netbeans, however compile-on-save and some syntax support would be great to as a starting point.
Comment 26 bennyn 2015-03-11 14:28:40 UTC
Yepp, Compile-on-Save and basic syntax highlighting would be great! But Petr Pisl wrote that it would be nice to have ANTLR grammar to kickstart something. So I wanted to check if I can finde something like this in the internet. :D I also pinged some guys from Microsoft. Maybe they support our idea to bring the TypeScript language to NetBeans IDE. Angular 2 is also build on top of TypeScript, so this will be a huge boost for TS itself (http://blogs.msdn.com/b/typescript/archive/2015/03/05/angular-2-0-built-on-typescript.aspx).
Comment 27 bennyn 2015-03-11 19:53:34 UTC
So, who is in for creating TypeScript support for our beloved NetBeans IDE? You can join the discussion that I started with the developers of the TypeScript language: https://twitter.com/jntrnr/status/575744099233333248 - Jonathan Turner suggests using the TS language server to parse and get an abstract syntax tree.
Comment 28 Petr Pisl 2015-03-12 10:14:58 UTC
I will look at the typescript-services etc. I haven't time yet.

We need coloring lexer and parser / AST producer. The parser itself needs a lexer as well, but very often coloring lexer is written separately because sometimes we expect something different than lexer for parser. Both the coloring lexer and parser has to be error prove. In 99% when you editing a file, the code is broken, so the parser has to have good error recovery to obtain as much information as possible for broken code. 

Also the parser has to be very fast. When you edit the code, then by default in NetBeans after 2 seconds from last change is the code parsed to reflect the changes. But this doesn't mean that the parser is running only once every 2 second when you are writing. Us I wrote, the code is broken and one technique how to obtain reasonable information from parser is "sanitized" the code. Which means that there is a heuristic, that is trying to "correct" the broken code without changing offsets other AST nodes. There can be more attempts to correct the broken code to obtain good AST from parser. So this means that the code is not parsed once after the change but it can be parsed 5 times or even more. It depends when the sanitizing the code and parsing such code produce reasonable AST.

From this point of view is clear that the parser has to be fast as much as possible. And if you call parser as an external process it can influence the performance a lot. 

We have to create prototype and we will see.
Comment 29 tiinusen 2015-03-12 21:49:38 UTC
Currently ec6 support (with babel) in dev progress by third party since NB have not yet given any accurate statement about their development on this matter.
Comment 30 dhaowoods 2015-03-18 03:26:08 UTC
AngularJS has been around a long while, Netbeans does have support for Knockout.JS by providing Knockout Client Generator, but, I wonder are there exist ngResource Client Generator, that could generate JAX-RS client?
Comment 31 elennaro 2015-03-21 13:26:17 UTC
According to WiKi http://wiki.netbeans.org/BugPriorityGuidelines this one should become P1 (more than 20 duplicates + votes).
Comment 32 weolopez 2015-05-06 22:27:14 UTC
Petr, check out https://www.youtube.com/watch?v=K6EBpMesubo and at the end you will see that Microsoft has provided a light weight compiler that provides a lot of the functionality for you.
Comment 33 Petr Pisl 2015-05-07 12:36:26 UTC
@weolopez: Thanks for the link. I'm going to look at this.
Comment 34 dhaowoods 2015-05-07 14:15:44 UTC
(In reply to Petr Pisl from comment #33)
> @weolopez: Thanks for the link. I'm going to look at this.

it seems like there is a bright future for typescript in netbeans :D
Comment 35 Ventzy 2015-07-10 22:22:21 UTC
After Angular 2 is released I expect use of TypeScript to explode. And as there is no additional information that Netbeans is considering TypeScript support in near future, let alone working on it, I am afraid that Netbeans will fail to deliver what market will need and lose more than few users. Currently I want to try TypeScript as it can deliver real value, and I cannot do anything in Netbeans.
Comment 36 Sarke 2015-07-10 22:43:14 UTC
I agree Ventzy.  I fear with the web moving to newer technologies like Typescript, Node+NPM, Grunt/Gulp, etc Netbeans will just get left behind.

If it doesn't step up it's web game, I think it will just revert to Java and stay there.

Myself I have been messing with VS Code, and it's so much less bloated than Netbeans (although I still use NB for my backend PHP work).
Comment 37 terje7601 2015-07-11 07:41:42 UTC
(In reply to Sarke from comment #36)
> I agree Ventzy.  I fear with the web moving to newer technologies like
> Typescript, Node+NPM, Grunt/Gulp, etc Netbeans will just get left behind.
> 
> If it doesn't step up it's web game, I think it will just revert to Java and
> stay there.
> 
> Myself I have been messing with VS Code, and it's so much less bloated than
> Netbeans (although I still use NB for my backend PHP work).

I'm sure the NetBeans developers are well aware of the importance of TypeScript support. Saying NetBeans will get left behind if it doesn't support it asap, isn't going to help.

Note that Node+NPM, Grunt/Gulp are all supported in the upcoming 8.1 ( http://wiki.netbeans.org/NewAndNoteworthyNB81 ). I've been using the dev builds for months now, and it works great.

On a final note: since TypeScript is a Microsoft project, it's to be expected that their IDE has great support for it.
Comment 38 dmitri616 2015-07-11 08:32:11 UTC
(In reply to terje7601 from comment #37)
> (In reply to Sarke from comment #36)
> 
> I'm sure the NetBeans developers are well aware of the importance of
> TypeScript support. Saying NetBeans will get left behind if it doesn't
> support it asap, isn't going to help.
> 
> On a final note: since TypeScript is a Microsoft project, it's to be
> expected that their IDE has great support for it.

This bug was open almost 2 years ago. The "well aware" argument is not a substitution for an action.
BTW, VS is not the only IDE with TypeScript support.
Comment 39 goodnickoff 2015-09-07 14:39:57 UTC
I was surprised that NB still does not support the typescript. Does anyone working on this now?
Comment 40 Petr Pisl 2015-09-08 08:23:45 UTC
I will work on this probably for the next release. We will see if there will be enough time to implement at least some basic features.
Comment 41 CyRaid 2015-09-08 09:16:51 UTC
(In reply to Petr Pisl from comment #40)
> I will work on this probably for the next release. We will see if there will
> be enough time to implement at least some basic features.

And he suddenly became everybodies hero.
Comment 42 dhaowoods 2015-09-08 15:27:25 UTC
I think it will make Netbeans more popular in AngularJS community if there is an official Generators for NetBeans IDE to create AngularJS clients for Java backends like this one from Mr. Geertjan Wielenga (https://github.com/GeertjanWielenga/KnockoutClientGenerators), it will boost productivity a lot
Comment 43 Petr Pisl 2015-09-09 08:58:34 UTC
(In reply to dhaowoods from comment #42)
> I think it will make Netbeans more popular in AngularJS community if there
> is an official Generators for NetBeans IDE to create AngularJS clients for
> Java backends like this one from Mr. Geertjan Wielenga
> (https://github.com/GeertjanWielenga/KnockoutClientGenerators), it will
> boost productivity a lot

Please fill a new issue / enhancement to track this separately. Thanks a lot.
Comment 44 Geertjan Wielenga 2015-09-30 07:26:33 UTC
A small start has been made on TypeScript support. All those interested in this issue are invited to join the project and contribute, via suggesting features, trying out the current status, and providing code:

https://github.com/GeertjanWielenga/TypeScript
https://blogs.oracle.com/geertjan/entry/ecmascript_typescript_and_netbeans_ide
Comment 45 urbiwan 2015-10-08 07:54:05 UTC
Hi just want to add the latest news  from the netbeans twitter account 

http://blog.everlaw.com/2015/10/06/open-source-typescript-netbeans/

Regards
Comment 46 Christian Lenz 2016-03-07 20:33:40 UTC
What should we do with this ticket? Resolved and fixed with a link to the plugin or what? Because this ticket is kind a dead now I think.
Comment 47 Petr Pisl 2016-03-08 07:35:00 UTC
We have discussed the future of the linked plugin with author. We would like to add it to the standard distro, but there has to be some work done. Unfortunately I don't have enough time to do it now. 

I would to keep this issue open, just as reminder of this.
Comment 48 Christian Lenz 2016-03-08 07:38:51 UTC
Nice, thx for the info :)
Comment 49 Rahul.khandelwal 2016-08-29 05:55:01 UTC
Any updates on native typescript support in netbeans ?
Comment 50 _ wadechandler 2016-08-31 10:58:19 UTC
I think the best fix for this would be something at least simalr to this:

Have the plugin portal upgraded to better support the 3rd party ecosystem, and too, for NB to sponsor a Cloudbees account, or something similar, for Jenkins and Sonar, and then to support plugin authors being able to auto submit plugins and suites etc to the plugin portal from the builds. There could be build pipeline steps NB owns which allows for signing and other things. It could even be there is an API at NB.org which allows authorized users to register new plugin git and hg repositories, and we 3rd party devs only control our build scripts, code, docs, and tests, along with supporting predefined hooks/tasks/goals that get us into that build. Then preapproved 3rd party plugins could appear more "native" as they would/could show up in the proper IDE plugin update centers, and this would encourage more of that IMO.

Beyind that, NB.org could also have some install generator similar to what http://start.spring.io does. This could prebundle modules selected by users either by exact module and dependencies or as an entire category of development, such as TypeScript or maybe "Angular 2".

Going further, the API I mentioned could allow for 3rd party auto update centers to be registered. Then, depending on curation and approval, could show up directly in NB installs, or be part of the generator both by module selection or added as a whole.

This would also make it easier for groups to start a 3rd party project, and contributors be able to take it over if needed, or drive most of the changes. It also is a path for plugins NB doesn't support as well now or gives to the community. NB could create a Bitbucket team, and have some things from NB managed on that infrastructure as they work with the community on transition.

It seems many efforts could be spent on NB trying to do all, or an effort on the ecosystem which provides more economy of scale for the wider community.
Comment 51 Christian Lenz 2020-06-13 21:48:47 UTC
Syntax highlighting based on textmate lexer and code completion/navigation was added via LSP. It is not as powerful as the NBTS plugin but it is working so far. So I will close this ticket now and please don't comment here, create new tickets on the new Apache NetBeans Board: https://issues.apache.org/jira/projects/NETBEANS