This repository was archived by the owner on Jan 13, 2026. It is now read-only.
Commit 63dea5b
Fix 960 boolean field inference (#961)
Fixes #960
### Summary
This PR fixes TypeScript type inference for boolean schema fields to
align with runtime behavior. Previously, boolean fields were typed as
`boolean | null`, but the `BooleanDataTransformer` always converts
`null` values to `false` at runtime, meaning boolean fields never
actually return `null`. This change updates the type inference to
correctly reflect that boolean fields always return `boolean`,
eliminating a type-safety gap where TypeScript allowed `null` handling
that would never execute.
### Technical Details
**Changed**: `InferSchemaType` type helper in `src/Schema.ts`
- Removed `InferRequiredType` wrapper from boolean type inference
- Boolean fields now directly infer as `boolean` regardless of the
`required` property
- Other scalar types (string, number, date/time) continue to respect
`required` and can still be `null`
### Breaking Changes
This is technically a breaking change for TypeScript consumers, though
it corrects a type-safety issue:
- Code that previously handled `null` values for boolean fields will now
show TypeScript errors
- However, such null checks were unnecessary since `null` is transformed
to `false` at runtime
- Users needing true tri-state logic (true/false/null as distinct
states) should use `string` type with `enum` constraint, as documented
---------
Co-authored-by: Shawn McKnight <smcknight@storis.com>1 parent 5f9bc22 commit 63dea5b
File tree
4 files changed
+11
-14
lines changed- src
- __tests__
4 files changed
+11
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
145 | 145 | | |
146 | 146 | | |
147 | 147 | | |
148 | | - | |
| 148 | + | |
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1061 | 1061 | | |
1062 | 1062 | | |
1063 | 1063 | | |
1064 | | - | |
| 1064 | + | |
1065 | 1065 | | |
1066 | 1066 | | |
1067 | 1067 | | |
| |||
1123 | 1123 | | |
1124 | 1124 | | |
1125 | 1125 | | |
1126 | | - | |
| 1126 | + | |
1127 | 1127 | | |
1128 | 1128 | | |
1129 | 1129 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2403 | 2403 | | |
2404 | 2404 | | |
2405 | 2405 | | |
2406 | | - | |
| 2406 | + | |
2407 | 2407 | | |
2408 | 2408 | | |
2409 | 2409 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
502 | 502 | | |
503 | 503 | | |
504 | 504 | | |
505 | | - | |
| 505 | + | |
506 | 506 | | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
| 507 | + | |
511 | 508 | | |
512 | 509 | | |
513 | 510 | | |
| |||
801 | 798 | | |
802 | 799 | | |
803 | 800 | | |
804 | | - | |
| 801 | + | |
805 | 802 | | |
806 | 803 | | |
807 | 804 | | |
| |||
896 | 893 | | |
897 | 894 | | |
898 | 895 | | |
899 | | - | |
| 896 | + | |
900 | 897 | | |
901 | 898 | | |
902 | 899 | | |
903 | | - | |
| 900 | + | |
904 | 901 | | |
905 | 902 | | |
906 | 903 | | |
| |||
1226 | 1223 | | |
1227 | 1224 | | |
1228 | 1225 | | |
1229 | | - | |
| 1226 | + | |
1230 | 1227 | | |
1231 | 1228 | | |
1232 | 1229 | | |
| |||
1317 | 1314 | | |
1318 | 1315 | | |
1319 | 1316 | | |
1320 | | - | |
| 1317 | + | |
1321 | 1318 | | |
1322 | 1319 | | |
1323 | 1320 | | |
| |||
0 commit comments