3

I need some help. I'm playing with basics of Angular2 and TypeScript as a part of my switch from A1 to A2 so something here might be obvious for you.

I have a this situation:

  1. Webpack in use.
  2. AppConfigConst holds some static, app wide configuration data.
  3. AppConfigurationInjectable takes AppConfigConst and exposes simple API to access configuration data.
  4. SelectedLanguageInjectable want's to use method from AppConfigConst and here I get this:

ERROR in [default] C:_DEV\XXX\src\app\shared\selected-language\selected-language.injectable.ts:9:46 Property 'getSupportedUiLanguages' does not exist on type 'typeof AppConfigurationInjectable'.

enter image description here

2
  • 3
    First of all paste code into questions, not screenshots. The issue is private appConfiguration **=** AppConfigurationInjectable. = should be :, since = defines default value for the parameter, not its type. Commented Dec 31, 2016 at 15:17
  • 1
    ...and your selectedLang is set as a string... shouldn't it be an array? Commented Dec 31, 2016 at 15:23

1 Answer 1

5

You have a mistake in your constructor. It should be:

constructor(private appConfiguration: AppConfigurationInjectable){

change = with :

: is for defining types in typescript = is for setting a value as you know.

Sign up to request clarification or add additional context in comments.

1 Comment

Specifically (in this case) a default function argument. So the appConfiguration variable winds up referring to the AppConfigurationInjectable interface/class itself rather than an instance.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.