zenstack/tests/regression/test/issue-204
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
..
input.ts chore: regenerate schemas (#575) 2026-01-08 16:59:49 +08:00
models.ts fix(schema): use type-only imports to prevent bundling server dependencies in client code (#668) 2026-02-07 23:25:23 +08:00
regression.test.ts fix(orm): update to kysely 0.28.x and simplify typing (#380) 2025-11-08 10:19:14 -08:00
schema.ts refactor(schema): widen types for attributes, default, and foreignKeyFor in generated schema 2026-03-12 19:51:43 -07:00
schema.zmodel refactor(orm): simplify model results typing (#485) 2025-12-13 16:59:03 +08:00