Tree upgrade error with PrimeNG 16 / Angular 16

UI Components for Angular
Post Reply
piglets
Posts: 6
Joined: 12 Nov 2016, 10:38

13 Jul 2023, 05:45

Hi,

Please can anyone help me with a compile error that has occurred after upgrading an Angular 15 / PrimeNG 15 project to Angular 16 / PrimeNG 16.
The project compiles fine using Angular 15 / PrimeNG 15.
The only change I can see documented to the TreeNode Interface is here: https://github.com/primefaces/primeng/issues/13183 but doesn't account for what I'm experiencing. Help would be most welcome.

Compile Error

Code: Select all

Error: src/app/edit/edit.component.html:28:116 - error TS2322: Type 'TreeNode<any> | TreeNode<any>[]' is not assignable to type 'TreeNode<any>'.
  Type 'TreeNode<any>[]' has no properties in common with type 'TreeNode<any>'.

28   <p-tree #tree id="treeid" [contextMenu]="topictree" [value]="db.treeNodes" selectionMode="single" [(selection)]="selectedNode" [validateDrop]="true" (onNodeDrop)="onDrop($event)" [filter]="true" filterMode="strict" [draggableNodes]="true" [droppableNodes]="true" draggableScope="self" droppableScope="self" (onNodeSelect)="nodeSelect($event.node)" (onNodeExpand)="nodeExpand($event.node)" [styleClass]="'topic-tree'" scrollHeight="auto">
The compiler will not accept the tree [(selection)] property being of type TreeNode.

Code: Select all

selectedNode!: TreeNode; // NOTE: html has tree property set as: selectionMode="single"
The only way I can get the project to compile successfully is by defining selectedNode property as type any:

Code: Select all

selectedNode!: any
package.json

Code: Select all

  "dependencies": {
    "@angular/animations": "^16.1.0",
    "@angular/common": "^16.1.0",
    "@angular/compiler": "^16.1.0",
    "@angular/core": "^16.1.0",
    "@angular/forms": "^16.1.0",
    "@angular/platform-browser": "^16.1.0",
    "@angular/platform-browser-dynamic": "^16.1.0",
    "@angular/router": "^16.1.0",
    "@tinymce/tinymce-angular": "^7.0.0",
    "crypto-js": "^4.1.1",
    "mysql2": "^3.5.0",
    "mysqldump": "^3.2.0",
    "primeflex": "^3.3.1",
    "primeicons": "^6.0.1",
    "primeng": "^16.0.2",
    "rxjs": "~7.8.0",
    "socket.io": "^4.7.1",
    "socket.io-client": "^4.7.1",
    "tinymce": "^6.5.1",
    "tslib": "^2.3.0",
    "zone.js": "~0.13.0"
  },

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 16 guests