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

Table/TreeTable: filters property might have undefined value when access by key #12321

Closed
steve3d opened this issue Dec 3, 2022 · 0 comments · Fixed by #12323
Closed

Table/TreeTable: filters property might have undefined value when access by key #12321

steve3d opened this issue Dec 3, 2022 · 0 comments · Fixed by #12323
Assignees
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Milestone

Comments

@steve3d
Copy link
Contributor

steve3d commented Dec 3, 2022

Describe the bug

In current version of Table and TreeTable there is a property filters which are declared as

@Input() filters: { [s: string]: FilterMetadata } = {};

@Input() filters: { [s: string]: FilterMetadata | FilterMetadata[] } = {};

this means any index key value will always return a non-null value, which is of course not right, it's a js object, when accessed with non-exists key, it will definitely return a undefined value.

So angular 13/14/15, will create this warning when I write dt.filters['closed']?.value === true:

Warning: resources/src/module-hr/department-list/department-list.component.html:34:65 - warning NG8107: The left side of this optional chain operation does not include 'null' or 'undefined' in its type, therefore the '?.' operator can be replaced with the '.' operator.

34                                [ngClass]="dt.filters['closed']?.value === 'true' ? 'bg-light-danger text-danger' : ''"
                                                                   ~~~~~

  resources/src/module-hr/department-list/department-list.component.ts:15:16
    15   templateUrl: './department-list.component.html',
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component DepartmentListComponent.

So these declaration is wrong, it should include type of undefined.

Environment

don't need an enviroment

Reproducer

No response

Angular version

any version with strict mode on

PrimeNG version

any

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

18.2.1

Browser(s)

Edge 107

Steps to reproduce the behavior

No response

Expected behavior

these filters should include undefined value in type declaration.

@steve3d steve3d added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Dec 3, 2022
@cetincakiroglu cetincakiroglu added Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Dec 29, 2022
@cetincakiroglu cetincakiroglu added this to the 15.0.1 milestone Dec 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add
Projects
None yet
2 participants