Skip to content
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

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

Conversation

@devversion
Copy link
Member

devversion commented Nov 7, 2019

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 label Nov 7, 2019
@devversion devversion force-pushed the devversion:refactor/coercion-inputs-accept-nuÃll-undefined branch from e4c81ca to 711350d Nov 7, 2019
Copy link
Member

crisbeto left a comment

LGTM


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

This comment has been minimized.

Copy link
@crisbeto

crisbeto Nov 7, 2019

Member

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.

This comment has been minimized.

Copy link
@devversion

devversion Nov 7, 2019

Author Member

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.

tools/tslint-rules/coercionTypesRule.ts Outdated Show resolved Hide resolved
tools/tslint-rules/coercionTypesRule.ts Show resolved Hide resolved
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 devversion:refactor/coercion-inputs-accept-nuÃll-undefined branch from 711350d to e6f3619 Nov 7, 2019
@devversion devversion marked this pull request as ready for review Nov 7, 2019
@devversion devversion requested review from andrewseguin, jelbourn, mmalerba and angular/dev-infra-components as code owners Nov 7, 2019
@devversion devversion added this to the 9.0.0 milestone Nov 7, 2019
Copy link
Member

jelbourn left a comment

LGTM

@mmalerba

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member Author

devversion commented Nov 7, 2019

@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

This comment has been minimized.

Copy link
Member

jelbourn commented Nov 8, 2019

Follow-up PR would be good

@devversion devversion added P1 and removed P2 labels Nov 8, 2019
@mmalerba mmalerba merged commit b56bcad into angular:master Nov 10, 2019
11 checks passed
11 checks passed
ci/angular: merge status All checks passed!
ci/circleci: api_golden_checks Your tests passed on CircleCI!
Details
ci/circleci: bazel_build Your tests passed on CircleCI!
Details
ci/circleci: build_release_packages Your tests passed on CircleCI!
Details
ci/circleci: e2e_tests Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: tests_browserstack Your tests passed on CircleCI!
Details
ci/circleci: tests_local_browsers Your tests passed on CircleCI!
Details
ci/circleci: tests_saucelabs Your tests passed on CircleCI!
Details
ci/circleci: view_engine_test Your tests passed on CircleCI!
Details
cla/google All necessary CLAs are signed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.