zenstack/samples
ymc9 1ba4e54066 refactor(schema): widen types for attributes, default, and foreignKeyFor in generated schema
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>
2026-03-12 19:51:43 -07:00
..
next.js refactor(schema): widen types for attributes, default, and foreignKeyFor in generated schema 2026-03-12 19:51:43 -07:00
nuxt refactor(schema): widen types for attributes, default, and foreignKeyFor in generated schema 2026-03-12 19:51:43 -07:00
orm refactor(schema): widen types for attributes, default, and foreignKeyFor in generated schema 2026-03-12 19:51:43 -07:00
shared feat(cli): implement watch mode for generate (#573) 2026-01-08 16:12:14 +08:00
sveltekit refactor(schema): widen types for attributes, default, and foreignKeyFor in generated schema 2026-03-12 19:51:43 -07:00