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 262514

Summary: Minimal Flow JS support
Product: javascript Reporter: Jenselme
Component: EditorAssignee: Petr Pisl <ppisl>
Status: NEW ---    
Severity: normal CC: Jenselme, phejl
Priority: P1    
Version: 8.2   
Hardware: PC   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:
Attachments: Wrong colors when varialbe declared with inline type annotation

Description Jenselme 2016-06-21 11:15:41 UTC
Created attachment 160115 [details]
Wrong colors when varialbe declared with inline type annotation

Inline type annotation are not part of ES6 but tools like babel supports it and some tools like flow promote them. It would be nice to have a support for them in nebteans.

Current behaviour:
- A variable declared with inline type annotation is reported as not declared.
- Syntax highlighting can be broken if multiple variable are declared (see attached screenshot).

Expected behaviour (in a first time):
- Provide an option to support inline type annotation (ie don't report them as error)
- Detect type annotation and propose the option
- Syntax highlighting should always be correct
- Variable declared with inline type annotation should always be considered declared.

In the long run
- Use annotations to report errors and help refactoring (with the help of flow?)

Sample code from flow getting started (https://flowtype.org/docs/getting-started.html#_):

var str: number = 'hello world!';
console.log(str);
Comment 1 Petr Pisl 2016-06-21 13:08:34 UTC
Treat it as enhancement.
Comment 2 Petr Hejl 2016-06-22 14:59:58 UTC
Is this ES8 spec?
https://github.com/sirisian/ecmascript-types
Comment 3 Jenselme 2016-06-22 15:53:50 UTC
It's not the official SPEC (as far as I know ES7 is not completed yet).

But from what I understand, the author off this document will propose this for ES7 (which makes sense since many dynamic and weakly typed languages (python3, perl6) are adding optional static types). I don't know if this will be accepted but I think it is very likely.
Comment 4 Petr Hejl 2016-06-24 16:37:49 UTC
(In reply to Jenselme from comment #3)
> It's not the official SPEC (as far as I know ES7 is not completed yet).
> 
> But from what I understand, the author off this document will propose this
> for ES7 (which makes sense since many dynamic and weakly typed languages
> (python3, perl6) are adding optional static types). I don't know if this
> will be accepted but I think it is very likely.

Looking here https://flowtype.org/docs/syntax.html#_
It's not actually the ES8 but proprietary similar syntax of the Flow and syntax extension not directly related to ES7 and ES8. We might evaluate a way for ignoring the type annotations (which is the way how it runs anyway).