如何从传播参数中提取类型?

时间:2019-03-28 20:11:02

标签: typescript

如何从数组中提取类型?我试图根据其顺序提取所有类型,以便在使用这些功能时能根据阵列中的位置知道哪种类型,以便更好地识别类型。

    export function toProviderResultObservable<T, R,
        A1 = never,
        A2 = never,
        A3 = never,
        A4 = never,
        A5 = never,
        A6 = never,
        >( result, mapFunc: (value?: T | undefined | null, ...values: [A1, A2, A3, A4, A5, A6]) => R | undefined | null) {

  result.then( args => 

                    let rawResult: T , frist, second, third, fourth, fifth, sixth;
                    if (isArray(arg)) {
                        rawResult = arg.shift() as T;
                        first = arg.shift() as A1;
                        second = arg.shift() as A2;
                        third = arg.shift() as A3;
                        fourth = arg.shift() as A4;
                        fifth = arg.shift() as A5;
                        sixth = arg.shift() as A6;
                    }
    mapFunc(rawResult as T, A1, A2, A3, A4, A5, A6, ...args)

   )}

0 个答案:

没有答案