Skip to content

fix(generator): emit an unknown record for field-less case classes - #96

Merged
jleider merged 2 commits into
masterfrom
fix/empty-case-class-unknown-record
Oct 6, 2026
Merged

jleider merged 2 commits into
masterfrom
fix/empty-case-class-unknown-record

Conversation

@jleider

@jleider jleider commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Depends on #95.

Field-less, non-generic case classes outside a union render as an open record instead of {}. typescript-eslint's @typescript-eslint/no-generated-empty-object-type rejects types that resolve to {}, and t.UnknownRecord decodes exactly what t.type({}) did (any non-array object, extra keys kept).

Before:

export type EmptyC = t.TypeC<{

}>;
export type Empty = {

};
export const emptyC: EmptyC = t.type({

}) satisfies t.Type<Empty, unknown>;

After:

export type EmptyC = t.UnknownRecordC;
export type Empty = Record<string, unknown>;
export const emptyC: EmptyC = t.UnknownRecord satisfies t.Type<Empty, unknown>;
  • TsGenerator classifies an interface as UnknownRecord or Fields (private InterfaceShape ADT) and renders the codec type, value type and codec from that.
  • TsImports.Available gains iotsUnknownRecord and iotsUnknownRecordC.
  • EmptyInterfaceTest pins the output for a field-less case class and a case class that references it.
  • scala-ts-generation and io-ts skills document the new mapping.
  • Consumer: https://github.com/mblink/bondlink/pull/13136 can drop its Main.scala post-processing override once this is released.

@jleider
jleider added this pull request to stack #97 October 5, 2026 19:54
…asses

- Field-less, non-generic case classes outside a union render as `Readonly<Record<string, unknown>>` with a `t.readonly(t.UnknownRecord)` codec instead of `{}` / `t.type({})`
- Adds `EmptyInterfaceTest` pinning the output
@jleider
jleider force-pushed the fix/empty-case-class-unknown-record branch from 32537b1 to fbc0c0b Compare October 6, 2026 17:06
@jleider
jleider marked this pull request as ready for review October 6, 2026 17:07
Base automatically changed from chore/claude-setup to master October 6, 2026 17:10
@jleider jleider changed the title fix(generator): emit a readonly unknown record for field-less case classes fix(generator): emit an unknown record for field-less case classes Oct 6, 2026
@jleider
jleider merged commit ca87782 into master Oct 6, 2026
6 checks passed
@jleider
jleider deleted the fix/empty-case-class-unknown-record branch October 6, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant