Skip to content

Commit

Permalink
use optional chaining in the type guard for greater safety (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
suddjian authored May 31, 2024
1 parent 6fd778c commit a92c62f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/renderer/type/type-guard-renderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class TypeGuardRenderer extends BaseContentTypeRenderer {
type: TypeGuardRenderer.WithContentTypeLink,
},
],
statements: `return entry.sys.contentType.sys.id === '${contentType.sys.id}'`,
statements: `return entry?.sys?.contentType?.sys?.id === '${contentType.sys.id}'`,
});

file.organizeImports({
Expand Down

0 comments on commit a92c62f

Please sign in to comment.