mirror of
https://github.com/zenstackhq/zenstack
synced 2026-05-24 10:08:55 +00:00
The generated schema previously used `as const` on entire model/enum/typeDef objects, causing TypeScript to deeply infer literal types for all nested properties. This is unnecessary for `attributes`, `default`, and `foreignKeyFor` which are only used at runtime, not in CRUD type computations. Changes: - Add type assertions (`as readonly AttributeApplication[]`, `as FieldDefault`, `as readonly string[]`) to prevent deep const inference on these properties - Extract `FieldDefault` type alias from `FieldDef` for cleaner generated code - Change `FieldHasDefault` to use key existence check (`'default' extends keyof`) instead of value type check, enabling the `default` widening - Conditionally import `AttributeApplication` and `FieldDefault` only when used Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| input.ts | ||
| models.ts | ||
| schema-lite.ts | ||
| schema.zmodel | ||