Changed mapEnumInput's signature

This commit is contained in:
Kir_Antipov 2022-10-18 21:26:17 +03:00
parent 2860874170
commit 5d39b55de2
2 changed files with 5 additions and 1 deletions

View file

@ -32,7 +32,7 @@ async function main() {
const files = await File.getRequiredFiles(fileSelector); const files = await File.getRequiredFiles(fileSelector);
const retryAttempts = mapNumberInput(options.retryAttempts); const retryAttempts = mapNumberInput(options.retryAttempts);
const retryDelay = mapNumberInput(options.retryDelay); const retryDelay = mapNumberInput(options.retryDelay);
const failMode = mapEnumInput(options.failMode, FailMode, FailMode.Fail as FailMode); const failMode = mapEnumInput<FailMode>(options.failMode, FailMode, FailMode.Fail);
const publisher = publisherFactory.create(target, logger); const publisher = publisherFactory.create(target, logger);
const func = { const func = {
func: () => publisher.publish(files, options), func: () => publisher.publish(files, options),

View file

@ -90,6 +90,10 @@ function findEnumValueByName<T extends EnumLike<U>, U>(enumClass: T, name: strin
return undefined; return undefined;
} }
export function mapEnumInput<T>(value: any, enumClass: any, defaultValue?: T): T;
export function mapEnumInput<T extends EnumLike<U>, U>(value: any, enumClass: T, defaultValue?: U): U;
export function mapEnumInput<T extends EnumLike<U>, U>(value: any, enumClass: T, defaultValue: U = null): U | null { export function mapEnumInput<T extends EnumLike<U>, U>(value: any, enumClass: T, defaultValue: U = null): U | null {
return mapInput(value, defaultValue, { return mapInput(value, defaultValue, {
string: (x: string) => { string: (x: string) => {