question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LocalizeRouterModule.forRoot returns a ModuleWithProviders type without a generic type argument

See original GitHub issue

I’m submitting a …

[x] bug report => Search github for a similar issue or PR before submitting

Full Error

  ERROR in node_modules/localize-router/src/localize-router.module.d.ts:33:68 - error NG6005: LocalizeRouterModule.forRoot returns a ModuleWithProviders type without a generic type argument. Please add a generic type argument
to the ModuleWithProviders type. If this occurrence is in library code you don't control, please contact the library authors.
    
    33     static forRoot(routes: Routes, config?: LocalizeRouterConfig): ModuleWithProviders;
                                                                          ~~~~~~~~~~~~~~~~~~~
    src/app/app-routing.module.ts:40:14 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class
    
    40 export class AppRoutingModule {}

🌍 Your Environment

Angular Version:


~9.0.0-rc.8

Localize Router Version:


"localize-router": "^2.0.0-RC.3",
"localize-router-http-loader": "^1.0.2",

app-routing.module.ts


import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import {HomeComponent} from './page/home/home.component';
import {ContactComponent} from './page/contact/contact.component';
import {TranslateService} from '@ngx-translate/core';
import {HttpClient} from '@angular/common/http';
import { Location } from '@angular/common';
import {LocalizeParser, LocalizeRouterModule, LocalizeRouterSettings} from 'localize-router';
import {LocalizeRouterHttpLoader} from 'localize-router-http-loader';

export function HttpLoaderFactory(translate: TranslateService, location: Location, settings: LocalizeRouterSettings, http: HttpClient) {
  return new LocalizeRouterHttpLoader(translate, location, settings, http);
}

const routes: Routes = [
  {
    path: '',
    pathMatch: 'full',
    component: HomeComponent
  },
  {
    path: 'contact',
    component: ContactComponent
  }
];

@NgModule({
  imports: [
    RouterModule.forRoot(routes),
    LocalizeRouterModule.forRoot(routes, {
      parser: {
        provide: LocalizeParser,
        useFactory: HttpLoaderFactory,
        deps: [TranslateService, Location, LocalizeRouterSettings, HttpClient]
      }
    })
  ],
  exports: [ RouterModule, LocalizeRouterModule ]
})
export class AppRoutingModule {}


Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:16
  • Comments:20

github_iconTop GitHub Comments

8reactions
gilsdavcommented, Mar 25, 2020

Or use fork that is compatible with Angular 9 https://github.com/gilsdav/ngx-translate-router

4reactions
ottodranikcommented, Mar 12, 2020

Can someone fix it for a compatibility with INY and Angular 9?

Here is a PR about that https://github.com/Greentube/localize-router/pull/174

Maybe it needed to fix the yaml file for CI and replace node v8 with node v12 to make this PR successful?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular error - Generic type 'ModuleWithProviders<T>' ...
d.ts:11:56 - error TS2314: Generic type 'ModuleWithProviders' requires 1 type argument(s). 11 static forRoot(options: TreeSelectDefaultOptions):Β ...
Read more >
Generic Types - StructureMap
ForObject(object subject) can only work with open types that have only one generic type parameter, and it will pass the argument subject to...
Read more >
angular/angular - Gitter
'User' only refers to a type, but is being used as a value here. ... static forRoot(): ModuleWithProviders { return { ngModule: CoreModule,Β ......
Read more >
Generic Types
Hence TypeGraphQL also has support for describing generic GraphQL types. ... has to be generic and take some runtime argument related to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found