Skip to content

chore: Add generics to typescript generator #4664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Oct 20, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Do not add ? to export type
  • Loading branch information
Emyrk committed Oct 20, 2022
commit daa5eec261c6c926f7e17d08cf9f97d6b92ce4f6
5 changes: 2 additions & 3 deletions scripts/apitypings/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,11 @@ func (g *Generator) buildUnion(obj types.Object, st *types.Union) (string, error
optional = optional || scriptType.Optional
}

qMark := ""
if optional {
qMark = "?"
allTypes = append(allTypes, "null")
}

s.WriteString(fmt.Sprintf("export type %s%s = %s\n", obj.Name(), qMark, strings.Join(allTypes, " | ")))
s.WriteString(fmt.Sprintf("export type %s = %s\n", obj.Name(), strings.Join(allTypes, " | ")))

return s.String(), nil
}
Expand Down