简体   繁体   中英

Angular Library Forroot AutoComplete / Intellisense

I am working on an Angular Library and wanting to have configs passed in. So far, all of that is working, but the issue I am having is when I go to setup the config in the app.module forroot, I do not have any intellisense for what config options are available.

If running it locally, shouldn't there be some intellisense so that the user knows what options they have to fill in? When I go to fill in baseUrl, I do not get any autocomplete/intellisense of what options are available to me.

FiltersModule.forRoot({
      baseUrl: CONFIG.baseUrl,
    } as any),

Library

export class FiltersModule {
  public static forRoot(configuration: Config): ModuleWithProviders {
    return {
      ngModule: FiltersModule,
      providers: [
        {
          provide: Config,
          useValue: configuration,
        },
      ],
    }
  }
}

export class Config {
    baseUrl?: string;
    baseUrlSSL?: string;
    clmTools?: string;
}

Also, I have this issue in both intellij and vscode

Thanks in advance!

Going to leave this up just in case some other poor unfortunate soul who should have taken a break a long time ago runs into this same issue lol.

In FiltersModule.forRoot, at the end it was casting it as any. That was my issue. So changing it from

FiltersModule.forRoot({
      baseUrl: CONFIG.baseUrl,
    } as any),

to

FiltersModule.forRoot({
  baseUrl: CONFIG.baseUrl,
}),

fixed my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM