Skip to content

Diagnostic when reading a required input from a constructor/initializer #63602

@alxhub

Description

@alxhub

There are circumstances where we can know statically that a required input is accessed in a context where it will not have a value:

id = input.required<number>();
data$ = httpClient.get('/api/user/' + this.id()); // id() read is statically in ctor scope

This is guaranteed to throw a runtime error. We can also produce a compiler diagnostic in this case.

Metadata

Metadata

Assignees

Labels

area: compilerIssues related to `ngc`, Angular's template compilercompiler: extended diagnosticsfeatureLabel used to distinguish feature request from other issues

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions