Skip to content

bug(cdk/coercion): coerceNumberProperty(thing, undefined) has invalid implementation or signature #29425

Closed

Description

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

coerceNumberProperty(thing, undefined) works the same way as coerceNumberProperty(thing), so it yields 0 if the thing isn't coercible to number. This is quite unexpected, because:

  1. In all other cases the fallback argument is respected.
  2. The return type is different: coerceNumberProperty(thing, undefined) returns number | undefined, even though the implementation always yields number.

Reproduction

StackBlitz link:
Steps to reproduce:
1.
2.

Expected Behavior

Fallback argument should be respected even for undefined.

Actual Behavior

undefined isn't respected as a fallback.

Environment

  • Angular: 17.0.6
  • CDK/Material: 17.1.0
  • Browser(s): *
  • Operating System (e.g. Windows, macOS, Ubuntu): *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsA relatively minor issue that is not relevant to core functionsarea: cdk/coercion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions