I'm only asking how the hell does this work. I'm porting from some legacy code. There is too much code to include it all here so I have tried to include only enough to be explanatory.
I am trying to recreate a component declared as below:
import * as Translations from "../dictionary.i18n";
...
@Component({
selector: "settingsgeneral",
templateUrl: './SettingsGeneral.template.html'
})
export class SettingsGeneralComponent extends SettingsGeneral {
...
constructor(settingsService: SettingsProvider, analyticsProvider: AnalyticsProvider) {
super(settingsService, Translations, analyticsProvider);
}
where ../dictionary.i18n.ts is a generated file that exports a whole lot of string constants for label texts.
The component derives from this class:
export class SettingsGeneral {
...
constructor(
private settingsService: ISettingsService,
private translations: GeneralTranslations,
private analyticsService: IAnalyticsService) {
}
And GeneralTranslations is an interface with a few string fields:
export interface GeneralTranslations {
ItemsPerPage:string;
FontSizeValues:string;
SettingsGeneralJurisdictionSortFilter:string;
}
How can the component template access fields on the translations property that aren't declared in GeneralTranslations? Notice how in the component ctor the imported module name, Translations (with upper-case T) is used as an argument for the call to the base class's ctor but in the base class that parameter is declared to be of type GeneralTranslations.
I'm guessing here that the type of the object actually passed to the base class ctor via the transactions parameter, being a set of constants, replaces the type GeneralTranslations. In the template I have, e.g. {{translations.StartPage}} but StartPage is not available on the GeneralTransactions interface yet it is available in the set of constants imported with from dictionary.i18n