21

I have a JavaScript class that takes one argument of type Object with defined set of properties and the Closure Compiler is happy when I annotate it like:

@constructor
@param {{ subview:BaseView, el:(jQuery|Element), title:String }} options
var MyView = function(options){ }

I would like to make title key optional and pass title value to some instances of my class and implement fallback behavior when this key is not present, so I annotated my class with:

@constructor
@param {{ subview:BaseView, el:(jQuery|Element), title:String= }} options
var MyView = function(options){ }

and now Closure Compiler is complaining:

WARNING - Bad type annotation. expected closing }

I've checked Annotating JavaScript for the Closure Compiler, but I see no single line describing such use case.

Mosh Feu
  • 28,354
  • 16
  • 88
  • 135
Pawel Dobierski
  • 407
  • 1
  • 4
  • 8
  • 2
    I think the `=` modifier is only valid for function parameters, not for record type properties. – Bergi Sep 10 '14 at 19:17

1 Answers1

25

@param {{ subview:BaseView, el:(jQuery|Element), title:(string|undefined) }} options

Tyler
  • 21,762
  • 11
  • 61
  • 90