Skip to content

refactor: allow coercion inputs to work with async pipe #17640

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

Conversation

devversion
Copy link
Member

We need to accept null and undefined for coercion members
to make them work with the async pipe. The overall problem
remains for other non-coercion inputs, but since the majority
of inputs are coerced, we only make the change to these.

The overall problem applies to all inputs, but it's not clear
yet how this issue can be solved for all inputs. This involves
discussion with the framework team.

More information: https://hackmd.io/@devversion/rkKOD8ZjB

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Nov 7, 2019
@devversion devversion force-pushed the refactor/coercion-inputs-accept-nuÃll-undefined branch from e4c81ca to 711350d Compare November 7, 2019 11:45
Copy link
Member

@crisbeto crisbeto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM


if (node.type.kind === ts.SyntaxKind.AnyKeyword) {
// if the type is "any", then it can be "null" and "undefined" too.
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to allow it to be any? Since it's something we control it might make sense to be a bit more strict.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some coercion members are set to any. i.e. the value input for mat-input's because otherwise value would only accept string while datepicker input accepts a date too.

So any is a special case that we allow.

We need to accept `null` and `undefined` for coercion members
to make them work with the `async` pipe. The overall problem
remains for other non-coercion inputs, but since the majority
of inputs are coerced, we only make the change to these.

The overall problem applies to _all_ inputs, but it's not clear
yet how this issue can be solved for all inputs. This involves
discussion with the framework team.

More information: https://hackmd.io/@devversion/rkKOD8ZjB
@devversion devversion force-pushed the refactor/coercion-inputs-accept-nuÃll-undefined branch from 711350d to e6f3619 Compare November 7, 2019 12:29
@devversion devversion marked this pull request as ready for review November 7, 2019 12:29
@devversion devversion added this to the 9.0.0 milestone Nov 7, 2019
Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@devversion devversion added the P2 The issue is important to a large percentage of users, with a workaround label Nov 7, 2019
@devversion devversion added the target: patch This PR is targeted for the next patch release label Nov 7, 2019
@jelbourn jelbourn added pr: lgtm action: merge The PR is ready for merge by the caretaker labels Nov 7, 2019
@mmalerba
Copy link
Contributor

mmalerba commented Nov 7, 2019

We could consider adding type aliases so that we don't repeat boolean | string | null | undefined everywhere, e.g.: BooleanInput, NumberInput

@devversion
Copy link
Member Author

@mmalerba Sounds like a good idea to me. We can do that as a follow-up if we all think it's reasonable. I'd be happy to switch to that.

@jelbourn
Copy link
Member

jelbourn commented Nov 8, 2019

Follow-up PR would be good

@devversion devversion added P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful and removed P2 The issue is important to a large percentage of users, with a workaround labels Nov 8, 2019
@mmalerba mmalerba merged commit b56bcad into angular:master Nov 10, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Dec 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P1 Impacts a large percentage of users; if a workaround exists it is partial or overly painful target: patch This PR is targeted for the next patch release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants