-
Notifications
You must be signed in to change notification settings - Fork 8
add type optional #382
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
add type optional #382
Conversation
164455b to
6aee811
Compare
6aee811 to
3cb14c4
Compare
3cb14c4 to
89c3486
Compare
89c3486 to
53937ce
Compare
53937ce to
343fd95
Compare
343fd95 to
9902a6e
Compare
bf764e8 to
cbb0f40
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for optional fields in the hypergraph schema system by introducing a Type.optional function and utilities to handle optional type checking throughout the codebase.
- Adds
Type.optionalexport and comprehensive type utilities for detecting optional fields - Updates serialization logic to handle optional fields by skipping undefined values or throwing errors for required fields
- Demonstrates the feature with optional fields in schema examples and practical usage in the events app
Reviewed Changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/hypergraph/src/type/type.ts | Exports Schema.optional as Type.optional |
| packages/hypergraph/src/type-utils/type-utils.ts | Adds utility functions to detect optional and specific optional field types |
| packages/hypergraph/src/index.ts | Exports the new TypeUtils module |
| packages/hypergraph-react/test/prepare-publish.test.ts | Comprehensive tests for the preparePublish function with optional field handling |
| packages/hypergraph-react/src/use-query.tsx | Removes commented-out legacy code for merging entities |
| packages/hypergraph-react/src/prepare-publish.ts | Updates to use TypeUtils for field type checking and optional field handling |
| packages/hypergraph-react/src/internal/use-query-public.tsx | Updates property value conversion to use TypeUtils |
| packages/hypergraph-react/src/internal/use-generate-update-ops.tsx | Removes entire file (was commented out) |
| packages/hypergraph-react/src/internal/use-create-entity-public.ts | Updates to use TypeUtils and handle optional fields |
| docs/docs/schema.md | Adds documentation for optional fields |
| apps/typesync/src/Generator.ts | Minor import ordering change |
| apps/events/src/schema.ts | Adds optional description field to Event schema |
| apps/events/src/mapping.ts | Adds mapping for the new description property |
| apps/events/src/components/ui/label.tsx | Adds new Label UI component |
| apps/events/src/components/playground.tsx | Increases query limit from 2 to 10 |
| apps/events/src/components/events/events.tsx | Updates UI to handle optional description field |
| apps/events/package.json | Adds @radix-ui/react-label dependency |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Text; | ||
| } | ||
| return type === Type.Text; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isNumberOrOptionalNumberType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Number; | ||
| } | ||
| return type === Type.Number; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isDateOrOptionalDateType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Date; | ||
| } | ||
| return type === Type.Date; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Checkbox; | ||
| } | ||
| return type === Type.Checkbox; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isPointOrOptionalPointType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Point; | ||
| } |
Copilot
AI
Jul 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function isStringOrOptionalStringType returns type === Type.Text in both branches of the conditional, making the conditional logic redundant. Consider simplifying this to just return type === Type.Text; or implementing proper optional type checking.
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Text; | |
| } | |
| return type === Type.Text; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isNumberOrOptionalNumberType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Number; | |
| } | |
| return type === Type.Number; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isDateOrOptionalDateType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Date; | |
| } | |
| return type === Type.Date; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Checkbox; | |
| } | |
| return type === Type.Checkbox; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isPointOrOptionalPointType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Point; | |
| } | |
| return type === Type.Text; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isNumberOrOptionalNumberType = (type: any) => { | |
| return type === Type.Number; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isDateOrOptionalDateType = (type: any) => { | |
| return type === Type.Date; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | |
| return type === Type.Checkbox; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isPointOrOptionalPointType = (type: any) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I don't disagree with the copilot response here that both branches are the same. Is there a reason for if the if check if it only returns the same as the else case?
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Text; | ||
| } | ||
| return type === Type.Text; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isNumberOrOptionalNumberType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Number; | ||
| } | ||
| return type === Type.Number; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isDateOrOptionalDateType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Date; | ||
| } | ||
| return type === Type.Date; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Checkbox; | ||
| } | ||
| return type === Type.Checkbox; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isPointOrOptionalPointType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Point; | ||
| } |
Copilot
AI
Jul 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function isNumberOrOptionalNumberType has the same logic issue as isStringOrOptionalStringType - both branches return the same value, making the conditional redundant.
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Text; | |
| } | |
| return type === Type.Text; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isNumberOrOptionalNumberType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Number; | |
| } | |
| return type === Type.Number; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isDateOrOptionalDateType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Date; | |
| } | |
| return type === Type.Date; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Checkbox; | |
| } | |
| return type === Type.Checkbox; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isPointOrOptionalPointType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Point; | |
| } | |
| return type === Type.Text; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isNumberOrOptionalNumberType = (type: any) => { | |
| return type === Type.Number; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isDateOrOptionalDateType = (type: any) => { | |
| return type === Type.Date; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | |
| return type === Type.Checkbox; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isPointOrOptionalPointType = (type: any) => { |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Text; | ||
| } | ||
| return type === Type.Text; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isNumberOrOptionalNumberType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Number; | ||
| } | ||
| return type === Type.Number; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isDateOrOptionalDateType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Date; | ||
| } | ||
| return type === Type.Date; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Checkbox; | ||
| } | ||
| return type === Type.Checkbox; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isPointOrOptionalPointType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Point; | ||
| } |
Copilot
AI
Jul 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function isDateOrOptionalDateType has the same logic issue - both branches return the same value, making the conditional redundant.
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Text; | |
| } | |
| return type === Type.Text; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isNumberOrOptionalNumberType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Number; | |
| } | |
| return type === Type.Number; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isDateOrOptionalDateType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Date; | |
| } | |
| return type === Type.Date; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Checkbox; | |
| } | |
| return type === Type.Checkbox; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isPointOrOptionalPointType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Point; | |
| } | |
| return type === Type.Text; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isNumberOrOptionalNumberType = (type: any) => { | |
| return type === Type.Number; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isDateOrOptionalDateType = (type: any) => { | |
| return type === Type.Date; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | |
| return type === Type.Checkbox; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isPointOrOptionalPointType = (type: any) => { |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Text; | ||
| } | ||
| return type === Type.Text; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isNumberOrOptionalNumberType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Number; | ||
| } | ||
| return type === Type.Number; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isDateOrOptionalDateType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Date; | ||
| } | ||
| return type === Type.Date; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Checkbox; | ||
| } | ||
| return type === Type.Checkbox; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isPointOrOptionalPointType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Point; | ||
| } |
Copilot
AI
Jul 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function isCheckboxOrOptionalCheckboxType has the same logic issue - both branches return the same value, making the conditional redundant.
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Text; | |
| } | |
| return type === Type.Text; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isNumberOrOptionalNumberType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Number; | |
| } | |
| return type === Type.Number; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isDateOrOptionalDateType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Date; | |
| } | |
| return type === Type.Date; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Checkbox; | |
| } | |
| return type === Type.Checkbox; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isPointOrOptionalPointType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Point; | |
| } | |
| return type === Type.Text; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isNumberOrOptionalNumberType = (type: any) => { | |
| return type === Type.Number; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isDateOrOptionalDateType = (type: any) => { | |
| return type === Type.Date; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | |
| return type === Type.Checkbox; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isPointOrOptionalPointType = (type: any) => { |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Text; | ||
| } | ||
| return type === Type.Text; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isNumberOrOptionalNumberType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Number; | ||
| } | ||
| return type === Type.Number; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isDateOrOptionalDateType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Date; | ||
| } | ||
| return type === Type.Date; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Checkbox; | ||
| } | ||
| return type === Type.Checkbox; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isPointOrOptionalPointType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Point; | ||
| } |
Copilot
AI
Jul 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function isPointOrOptionalPointType has the same logic issue - both branches return the same value, making the conditional redundant.
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Text; | |
| } | |
| return type === Type.Text; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isNumberOrOptionalNumberType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Number; | |
| } | |
| return type === Type.Number; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isDateOrOptionalDateType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Date; | |
| } | |
| return type === Type.Date; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Checkbox; | |
| } | |
| return type === Type.Checkbox; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isPointOrOptionalPointType = (type: any) => { | |
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | |
| return type === Type.Point; | |
| } | |
| return type === Type.Text; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isNumberOrOptionalNumberType = (type: any) => { | |
| return type === Type.Number; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isDateOrOptionalDateType = (type: any) => { | |
| return type === Type.Date; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | |
| return type === Type.Checkbox; | |
| }; | |
| // biome-ignore lint/suspicious/noExplicitAny: TODO | |
| export const isPointOrOptionalPointType = (type: any) => { |
cmwhited
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check comment on is{Type}OrOptional{Type}Type fn
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Text; | ||
| } | ||
| return type === Type.Text; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isNumberOrOptionalNumberType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Number; | ||
| } | ||
| return type === Type.Number; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isDateOrOptionalDateType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Date; | ||
| } | ||
| return type === Type.Date; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isCheckboxOrOptionalCheckboxType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Checkbox; | ||
| } | ||
| return type === Type.Checkbox; | ||
| }; | ||
|
|
||
| // biome-ignore lint/suspicious/noExplicitAny: TODO | ||
| export const isPointOrOptionalPointType = (type: any) => { | ||
| if (type.ast && type.ast._tag === 'PropertySignatureDeclaration' && type.ast.isOptional) { | ||
| return type === Type.Point; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I don't disagree with the copilot response here that both branches are the same. Is there a reason for if the if check if it only returns the same as the else case?
|
@cmwhited excellent catch! fixed it and added tests for more optional cases |
No description provided.