-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ListKeyManager activeItem property has wrong type #14152
Labels
P4
A relatively minor issue that is not relevant to core functions
Comments
crisbeto
added a commit
to crisbeto/material2
that referenced
this issue
Nov 15, 2018
The `activeItem` is currently typed to `T | null`, however on init and when assigning incorrect values, the `activeItem` will actually be `undefined` at runtime. These changes add some logic to make sure that the value is consistent with its type. Fixes angular#14152.
crisbeto
added a commit
to crisbeto/material2
that referenced
this issue
Nov 15, 2018
The `activeItem` is currently typed to `T | null`, however on init and when assigning incorrect values, the `activeItem` will actually be `undefined` at runtime. These changes add some logic to make sure that the value is consistent with its type. Fixes angular#14152.
crisbeto
added a commit
to crisbeto/material2
that referenced
this issue
Nov 15, 2018
The `activeItem` is currently typed to `T | null`, however on init and when assigning incorrect values, the `activeItem` will actually be `undefined` at runtime. These changes add some logic to make sure that the value is consistent with its type. Fixes angular#14152.
josephperrott
pushed a commit
to josephperrott/components
that referenced
this issue
Jan 14, 2019
…ngular#14154) The `activeItem` is currently typed to `T | null`, however on init and when assigning incorrect values, the `activeItem` will actually be `undefined` at runtime. These changes add some logic to make sure that the value is consistent with its type. Fixes angular#14152.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Bug, feature request, or proposal:
ListKeyManager activeItem property has a wrong type
What is the expected behavior?
The
activeItem
property can beundefined
in some cases, so the typing should be aware of theundefined
as well. Another way would be to handle undefined value and returnnull
then.What is the current behavior?
The
activeItem
type is set toT | null
, but happens to returnundefined
.What are the steps to reproduce?
https://stackblitz.com/edit/angular-material-ticket-active-item-type
What is the use-case or motivation for changing an existing behavior?
In some cases (no value selected, non-existing value selected) the property can be also undefined which is not suggested by typing. Due to that fact, we recently faced a null pointer exception, because we only handled
null
value.Which versions of Angular, Material, OS, TypeScript, browsers are affected?
It affects
@angular/cdk
in version 6.3.0+ for sure, although it looks like the code is quite old, so previous version are probably affected as well.The text was updated successfully, but these errors were encountered: