(fld, fldType string, isAnyType bool)
| 952 | } |
| 953 | |
| 954 | func (t *typeScriptClassBuilder) addField(fld, fldType string, isAnyType bool) { |
| 955 | isOptional := strings.HasSuffix(fld, "?") |
| 956 | strippedFieldName := strings.ReplaceAll(fld, "?", "") |
| 957 | if !regexp.MustCompile(jsVariableNameRegex).Match([]byte(strippedFieldName)) { |
| 958 | fld = fmt.Sprintf(`"%s"`, strippedFieldName) |
| 959 | if isOptional { |
| 960 | fld += "?" |
| 961 | } |
| 962 | } |
| 963 | if isAnyType { |
| 964 | fldType = strings.Split(fldType, ".")[0] |
| 965 | t.fields = append(t.fields, fmt.Sprint(t.indent, "// Go type: ", fldType, "\n", t.indent, fld, ": any;")) |
| 966 | } else { |
| 967 | t.fields = append(t.fields, fmt.Sprint(t.indent, fld, ": ", fldType, ";")) |
| 968 | } |
| 969 | } |
| 970 | |
| 971 | func indentLines(str string, i int) string { |
| 972 | lines := strings.Split(str, "\n") |
no outgoing calls
no test coverage detected