| 553 | } |
| 554 | |
| 555 | func (t *TypeScriptify) getFieldOptions(structType reflect.Type, field reflect.StructField) TypeOptions { |
| 556 | // By default use options defined by tags: |
| 557 | opts := TypeOptions{TSTransform: field.Tag.Get(tsTransformTag), TSType: field.Tag.Get(tsType)} |
| 558 | |
| 559 | overrides := []TypeOptions{} |
| 560 | |
| 561 | // But there is maybe an struct-specific override: |
| 562 | for _, strct := range t.structTypes { |
| 563 | if strct.FieldOptions == nil { |
| 564 | continue |
| 565 | } |
| 566 | if strct.Type == structType { |
| 567 | if fldOpts, found := strct.FieldOptions[field.Type]; found { |
| 568 | overrides = append(overrides, fldOpts) |
| 569 | } |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | if fldOpts, found := t.fieldTypeOptions[field.Type]; found { |
| 574 | overrides = append(overrides, fldOpts) |
| 575 | } |
| 576 | |
| 577 | for _, o := range overrides { |
| 578 | if o.TSTransform != "" { |
| 579 | opts.TSTransform = o.TSTransform |
| 580 | } |
| 581 | if o.TSType != "" { |
| 582 | opts.TSType = o.TSType |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | return opts |
| 587 | } |
| 588 | |
| 589 | func (t *TypeScriptify) getJSONFieldName(field reflect.StructField, isPtr bool) string { |
| 590 | jsonFieldName := "" |