Skip to content

Commit c51b328

Browse files
authored
Fix optional chaining and type assertion in CreateTypes
1 parent fd84b4d commit c51b328

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/theme/JSONSchemaViewer/components/CreateTypes.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function RenderMultipleTypes(props: MultipleTypesProps): JSX.Element {
4242
const { schema, types, nullable } = props
4343

4444
return (
45-
<Tabs defaultValue={types[0].value} values={types} key={"multiple_types"}>
45+
<Tabs defaultValue={types[0]?.value} values={types} key={"multiple_types"}>
4646
{types.map((val) => (
4747
<TabItem key={val.value} value={val.value}>
4848
{
@@ -81,7 +81,7 @@ export default function CreateTypes(props: Props): JSX.Element {
8181
if (foundTypes.length === 1 || (hasNull && foundTypes.length === 2)) {
8282
// Either we got the not null type (likely what the final user wants to express)
8383
// Either we consider first entry as fallback if it was a standalone "null"
84-
const firstType = foundTypes.find((s) => s !== "null") || foundTypes[0]
84+
const firstType = (foundTypes.find((s) => s !== "null") || foundTypes[0]) as TypeValues
8585

8686
return (
8787
<RenderSingleType schema={schema} type={firstType} nullable={hasNull} />

0 commit comments

Comments
 (0)