MegaMenu doesn't compile with TypeScript 2.4 #3640
Labels
Type: Bug
Issue contains a bug related to a specific component. Something about the component is not working
Milestone
I'm submitting a ...
Test case
You can use the following demo app as test case:
https://github.com/ova2/angular-development-with-primeng/tree/master/chapter7/megamenu
Current behavior
If you run the showcase for the MegaMenu with TypeScript 2.4 or run the demo app linked above, you will get a compilation error like
Expected behavior
There should be no compilation error, as when compiling with TypeScript 2.3.
Minimal reproduction of the problem with instructions
Install the above app
or install the current master of PrimeNG and change the requirements in package.json to Angular 4.3, Angular-Cli 1.3, TypeScript 2.4 (lower Angular/Cli versions require TypeScript 2.3, so you need to test with Angular 4.3 and Cli 1.3)
Run
npm
install andnpm start
and check the MegaMenuAngular version: 4.3.3
PrimeNG version: 4.1.2
Browser: all
Language: TypeScript 2.4
Node (for AoT issues): 8.1.4
Analysis of the problem:
In the
MenuItem
interface, theitems
property is defined as of typeMenuItem[]
. But in the MegaMenu, you can have arrays of arrays of MenuItems as items, not just arrays of MenuItems.In TypeScript 2.4, it’s now an error to assign anything to a weak type when there’s no overlap in properties (see here).
Note that in the
MenuItem
interface all properties are marked as optional. Therefore, this is considered a "weak type".The
items
property in theMenutItem
interface should be defined as follows:The text was updated successfully, but these errors were encountered: