Skip to content

Signal forms: Generics don't work the same as regular objects #65535

@Harpush

Description

@Harpush

Which @angular/* package(s) are the source of the bug?

forms

Is this a regression?

No

Description

In regular object if I have a generic function with T as object union I can access shared properties:

function test<T extends { a: number; b: string } | { a: number; c: boolean }>(value: T) {
  console.log(value.a);
}

But when using FieldTree I cannot access shared properties:

function test2<T extends { a: number; b: string } | { a: number; c: boolean }>(value: FieldTree<T>) {
  console.log(value.a); // errors
}

It does work with regular union (no generics):

function test3(value: FieldTree<{ a: number; b: string } | { a: number; c: boolean }>) {
  console.log(value.a);
}

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/edit/bw2bfa5z-qkpmcxjo?file=src%2Fmain.ts

Please provide the exception or error you saw


Please provide the environment you discovered this bug in (run ng version)

Angular 21

Anything else?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions