Skip to content

Commit 481e498

Browse files
committed
Do not add ? to export type
1 parent 247bb1e commit 481e498

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

scripts/apitypings/main.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,11 @@ func (g *Generator) buildUnion(obj types.Object, st *types.Union) (string, error
312312
optional = optional || scriptType.Optional
313313
}
314314

315-
qMark := ""
316315
if optional {
317-
qMark = "?"
316+
allTypes = append(allTypes, "null")
318317
}
319318

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

322321
return s.String(), nil
323322
}

0 commit comments

Comments
 (0)