-
Notifications
You must be signed in to change notification settings - Fork 27.1k
QueryList's filter method doesn't support type guards #38446
Copy link
Copy link
Closed
Labels
P4A relatively minor issue that is not relevant to core functionsA relatively minor issue that is not relevant to core functionsarea: coreIssues related to the framework runtimeIssues related to the framework runtimecore: queriescross-cutting: typesfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfeature: under considerationFeature request for which voting has completed and the request is now under considerationFeature request for which voting has completed and the request is now under considerationfreq2: medium
Milestone
Description
🐞 bug report
Affected Package
The issue is caused by package @angular/core.
Is this a regression?
No, it has never worked properly.
Description
Using a type guard as the argument for the QueryList#filter method doesn't narrow the type of the resulting array as expected. It's expected because it works when using Array#filter, which the documentation tells me to see.
🔬 Minimal Reproduction
See line 24, and compare with 26-29.
🔥 Exception or Error
Property 'hello' does not exist on type 'HelloComponent | ByeComponent'.
Property 'hello' does not exist on type 'ByeComponent'.
🌍 Your Environment
Angular Version: all
The fix is trivial and can be seen here:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P4A relatively minor issue that is not relevant to core functionsA relatively minor issue that is not relevant to core functionsarea: coreIssues related to the framework runtimeIssues related to the framework runtimecore: queriescross-cutting: typesfeatureLabel used to distinguish feature request from other issuesLabel used to distinguish feature request from other issuesfeature: under considerationFeature request for which voting has completed and the request is now under considerationFeature request for which voting has completed and the request is now under considerationfreq2: medium