Skip to content

Angular compiler strips | null from signal input types in partial compilation .d.ts output #67706

@thomaswinckell

Description

@thomaswinckell

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

compiler

Is this a regression?

Yes

Description

When using input.required<T | null>() or input<T | null>() in a library built with ng-packagr (partial compilation mode), the Angular compiler strips | null from the generated .d.ts files.

Source:

a = input.required<T | null>();
b = input<T | null>();

Expected .d.ts (matches plain tsc --emitDeclarationOnly):

a: InputSignal<T | null>;
b: InputSignal<T | null | undefined>;

Actual .d.ts from Angular compiler (partial mode):

 a: _angular_core.InputSignal<T>; 
 b: _angular_core.InputSignal<T>;

Investigation:
I intercepted the in-memory .d.ts content from ng-packagr's file cache (before rollup-plugin-dts bundling) and confirmed | null was already missing at that stage. Plain tsc --emitDeclarationOnly on the same source produces correct types.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw


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

Angular 21.2.x, ng-packagr 21.2.0, TypeScript 5.9.3

Anything else?

A workaround is to force the type and not rely on type inference.
Example:

a: InputSignal<T | null> = input<T| null>();

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: compilerIssues related to `ngc`, Angular's template compilergemini-triagedLabel noting that an issue has been triaged by geminineeds reproductionThis issue needs a reproduction in order for the team to investigate further

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions