   _jsonDef: ->
     @_def
   type: ->
-    @_type
+    @_def.type?.kind || @_def.type
   isStruct: ->
-    @_type == 'struct'
+    @type() == 'struct'
   path: ->
     (if @_parent then @_parent.path() else []).concat(@_name)
 
 class ValueMemberField extends MemberField
-  constructor: (parent, name, type, def) ->
-    super(parent, name, type, def)
+  constructor: (parent, name, def) ->
+    super(parent, name, def)
   visit: (callback) ->
     callback(@)
 
 class StructMemberField extends MemberField
   constructor: (parent, name, def) ->
-    super(parent, name, 'struct', def)
+    super(parent, name, def)
     @_fields = [] # Array of MemberField
   fields: ->
     @_fields



class MemberField
  constructor: (@_parent, @_name, @_type, @_def) ->
  name: ->
    @_name
  label: ->

      @_appendFields(res, res.fields(), def.type.members, def)
      res
    else
      new ValueMemberField(parent, name, def)
  _appendFields: (parent, target, members) ->
    for name, def of members
      target.push @_buildMemberField(parent, name, def)
