MCPcopy
hub / github.com/wailsapp/wails / Convert

Method Convert

v2/internal/typescriptify/typescriptify.go:393–422  ·  view source on GitHub ↗
(customCode map[string]string)

Source from the content-addressed store, hash-verified

391}
392
393func (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
424func loadCustomCode(fileName string) (map[string]string, error) {
425 result := make(map[string]string)

Callers 2

ConvertToFileMethod · 0.95
GenerateModelsMethod · 0.80

Calls 2

convertEnumMethod · 0.95
convertTypeMethod · 0.95

Tested by

no test coverage detected