(customCode map[string]string)
| 391 | } |
| 392 | |
| 393 | func (t *TypeScriptify) Convert(customCode map[string]string) (string, error) { |
| 394 | t.alreadyConverted = make(map[string]bool) |
| 395 | depth := 0 |
| 396 | |
| 397 | result := "" |
| 398 | if len(t.customImports) > 0 { |
| 399 | // Put the custom imports, i.e.: `import Decimal from 'decimal.js'` |
| 400 | for _, cimport := range t.customImports { |
| 401 | result += cimport + "\n" |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | for _, enumTyp := range t.enumTypes { |
| 406 | elements := t.enums[enumTyp.Type] |
| 407 | typeScriptCode, err := t.convertEnum(depth, enumTyp.Type, elements) |
| 408 | if err != nil { |
| 409 | return "", err |
| 410 | } |
| 411 | result += "\n" + strings.Trim(typeScriptCode, " "+t.Indent+"\r\n") |
| 412 | } |
| 413 | |
| 414 | for _, strctTyp := range t.structTypes { |
| 415 | typeScriptCode, err := t.convertType(depth, strctTyp.Type, customCode) |
| 416 | if err != nil { |
| 417 | return "", err |
| 418 | } |
| 419 | result += "\n" + strings.Trim(typeScriptCode, " "+t.Indent+"\r\n") |
| 420 | } |
| 421 | return result, nil |
| 422 | } |
| 423 | |
| 424 | func loadCustomCode(fileName string) (map[string]string, error) { |
| 425 | result := make(map[string]string) |
no test coverage detected