How can I use closure type annotation with Aptana?
Asked Answered
P

1

6

If I enter the follow JavaScript code in Aptana Studio 3 then I expect some errors but it show nothing.

/**
 * @type {string}
 */
var abc = 23;
abc.doesNotExists();

How can I enable the support for closure type annotation?

Placidia answered 8/12, 2012 at 17:51 Comment(6)
I'm not sure what error you're expecting. 23 is a valid value for a variable.Papule
23 is not a valid string. doesNotExist() is not a valid for a string.Placidia
You're not declaring a string, you're declaring a variable. var means the value could be any number of things, including an integer.Papule
@Papule do you know what "closure type annotation" are? "@type {string}" declare a string variable. The closure compiler give a compiler error. But I want that the editor already show an error. Also the auto completion should show only methods for string like in other editors. for example Komodo.Placidia
@horcrux7 For that reason (and many others) I use JetBrains WebStorm IDE...Cuyp
What version of Aptana are you using? That feature was added in 3.0.7.Gaut
T
0

Currently Aptana supports only the annotations but not also the actual type checking. In order to type check you have to compile that code using the google closure compiler. If you set the compiler to the full optimized mode it will yell the warning that abc is a string ( as you placed it in the annotation comment ), but you have set a number value instead. In order to be able to take this from the command line of the closure compiler and integrate it into aptana you would need a plugin, but as far as i know, the closure plugin for eclipse/aptana has not been updated for the last 1 or 2 years, and also this feature that you would like to have was not implemented in the latest release of that plugin.

In other words, either you run the closure compiler separately and check the for warnings or errors in certain files, OR you fork the repo of the eclipse closure plugin and implement this feature yourself.

I had the same issue as you, but having too much work to do pushed me into opting for the first solution ( running the closure compiler separately in a console ). I had even placed a hook so each time i would save a file in that project it would run the compiler in the console view of aptana so i could check if i had introduced new errors or warnings.

Trefoil answered 22/1, 2015 at 23:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.