Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/typescript/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript:尝试为redux存储构建自动完成_Typescript - Fatal编程技术网

Typescript:尝试为redux存储构建自动完成

Typescript:尝试为redux存储构建自动完成,typescript,Typescript,我已经4个小时了,我一直在努力,但还是一无所获! Redux具有一些自动完成功能,如: store.getState().test.hello我正在尝试实现类似的目标。 测试减速器: const initialState = { hello: "adssad", }; export default (state = initialState, action) => { switch (action.type) { } return st

我已经4个小时了,我一直在努力,但还是一无所获! Redux具有一些自动完成功能,如:
store.getState().test.hello
我正在尝试实现类似的目标。 测试减速器:

const initialState = {
    hello: "adssad",
};

export default (state = initialState, action) => {
    switch (action.type) {
    }
    return state;
};

我现在创建了两个函数,可以分两步自动完成,但一步也做不到

export const testSSS = <R>(reducer: Reducer<R, any>): R => {
    return null;
};

export const testSSSS = <R, K>(reducers: R, key: keyof R) => {
    const reducer = reducers[key];
    return null as Reducer<typeof reducer, any>;
};
export const testSSS=(reducer:reducer):R=>{
返回null;
};
export const testSSSS=(减速器:R,键:keyof R)=>{
常数减速机=减速机[键];
返回null作为Reducer;
};
他们是这样做的:

    const test = testSSSS(
        {
            test: testReducer,
        },
        "test"// <--- this has auto completion
    );
const test=testSSSS(
{
测试:测试减速器,
},
“测试”//
testSSS(testReducer)
    .hello; <--- this has auto completion