Issue with Integrating MainMenu in ASP.NET CORE project

Post Reply
Posts: 5
Joined: 26 Nov 2017, 12:22

02 Feb 2018, 03:12

I am struggling to integrate the main menu in core project.

My webpack.config's loaders specified as following:

Code: Select all

[b]module: {
            rules: [
                test: /\.ts$/, use: isDevBuild ?
                  ['awesome-typescript-loader?silent=true', 'angular2-template-loader', 'angular2-router-loader']
                  : '@ngtools/webpack'
                { test: /\.html$/, use: 'html-loader?minimize=false' },
                { test: /\.css$/, use: [ 'to-string-loader', isDevBuild ? 'css-loader' : 'css-loader?minimize' ] },
                { test: /\.(png|jpg|jpeg|gif|svg)$/, use: 'url-loader?limit=25000' }
When I integrate app-menu (copied the source code and dependencies) I am getting following error

Code: Select all

[color=#FF0000]ERROR [/color]in ./ClientApp/app/components/navmenu/navmenu.component.ts
Module parse failed: E:\Personal\SchoolQuizApp\SchoolQuiz\node_modules\awesome-typescript-loader\dist\entry.js?silent=true!E:\Personal\SchoolQuizApp\SchoolQuiz\node_modules\angular2-template-loader\index.js!E:\Personal\SchoolQuizApp\SchoolQuiz\node_modules\angular2-router-loader\src\index.js!E:\Personal\SchoolQuizApp\SchoolQuiz\ClientApp\app\components\navmenu\navmenu.component.ts [b]'return' outside of function (267:8)[/b]
You may need an appropriate loader to handle this file type.
|     if (item.disabled) {
|         event.preventDefault();
|         return true;
|     }
|     // activate current item and deactivate active sibling if any
 @ ./ClientApp/app/app.shared.module.ts 16:0-95
 @ ./ClientApp/app/app.browser.module.ts
 @ ./ClientApp/boot.browser.ts
 @ multi event-source-polyfill webpack-hot-middleware/client?path=__webpack_hmr&dynamicPublicPath=true ./ClientApp/boot.browser.ts

In the SubmenuComponent >> Itemmenu function, not all code paths return a value. Is it not a bug? Can you please let me know how do I fix this error. I did spend 2 days on it so far.

Posts: 5
Joined: 26 Nov 2017, 12:22

02 Feb 2018, 14:09

ImageDear Serenity Creator/Admin,
I've found the solution to my problem. It is because of your poor programming standards. (I spent 2 days on this issue)

These are the steps I did to resolve this issue
1) Create exclusive component for AppSubMenuComponent. It has been merged with app-menu component. (My webpack.config is not happy with it and started throwing completely irrelevant error messages such as try different loader)

2) There is a problem with this line in AppSubMenuComponent

Code: Select all

this.activeIndex = (this.activeIndex as number === index) ? null : index;
here 'activeIndex' is declared as a number datatype but assigning a null value. No wonder a good compiler throw an error on this. (poor programming)

Replaced 'null' value with 0.

3) In the app.Mneu.component.ts file I did add the datatype for 'event' and theme

I know VIsual studio code editor is not throwing any errors for these but Visual Studio 2017 is showing above-mentioned issues as errors. I paid for it just to save my time, now I ended up fixing your poor practices.

You Owe me.

Can you please let me know why shouldn't I give this a poor rating?

Thank you.

Posts: 18017
Joined: 05 Jan 2009, 00:21
Location: Cybertron

09 Feb 2018, 11:38

It is open for debate whether it is a bad practice since point of view differs between compilers. For example, Angular CLI has no issue with this, linting has no issues but your webpack plugin does not like it. The code perfectly matches Angular CLI standards but your custom case had an issue with it, still we are ok with changing null to an integer, I think -1 might even be better. Thank you for the feedback although the way you express it is a bit harsh.

Post Reply

Return to “Serenity - PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest