Seems that this flags array for union type does not really work for me.
I have been playing with idea that implementing class must provide flags about interfaces it's implementing which is also easy to get out from implementing class.
Flags as flags: Record<T & FeatureFlagType, true>
works, but this also doable with array context?
I have tried with all different combinations for flags like (T & FeatureFlag)[] but nothing seem to work.
type FeatureFlagType = 'feature1' | 'feature2';
interface FeatureFlag<T extends FeatureFlagType> {
flags: T[];
flagsRecords: Record<T, true>;
}
interface Feature1 extends FeatureFlag<'feature1'> {
doFeature1: () => void;
}
interface Feature2 extends FeatureFlag<'feature2'> {
doFeature2: () => void;
}
class Instance implements Feature1, Feature2 {
public flags = ['feature1' as 'feature1', 'feature2' as 'feature2']; // not ok
public flagsRecords = {feature1: true as true, feature2: true as true}; // this is ok
public doFeature1() {
}
public doFeature2() {
}
}