How I can remove hardcoded string literals from isValidTaskID function and refer to Config keys instead?
type Config = {
markupPreprocessing?: MarkupPreprocessingSettings;
stylesPreprocessing?: StylesPreprocessingSettings;
};
type TasksIDs = keyof ProjectBuilderRawValidConfigFromFile;
fuction isValidTaskID(taskID: string): void {
return taskID === "markupPreprocessing" || taskID === "stylesPreprocessing";
}
// I still need the TasksIDs tuple!
type TasksAndEntryPontsSelection: Record<TasksIDs, Array<string>>;
isValidTaskIDat all. Where are you using this function? You could instead adjust those usages such that they cause the TS compiler to type check againstkeyof Config.Configanywhere in your code which fully specifies all possible properties? If you do, you could always do an alternative dynamic check:function isValidTaskID(taskID: string) { return Object.keys(instance).some(key => taskID === key) }. Otherwise, I don't think you can escape having to do those explicit checks.Configisn't compiled into any code, it's only used for type-checking.