The following code is a ngrx 4 reducer could you make it compatible for ngrx 16 so it works with createReducer()

export function reducer(state = initialState, action: any): State {
  switch (action.type) {
    case exportStream.ActionTypes.UPDATE_DEFAULT_REPETITION_RATE_SUCCESS: {
      let drr: DefaultRepetitionRate = action.payload.defaultRepetitionRate;
      let updatedTables: any[] = action.payload.updatedTables;
      let defaultRepetitionRates = [...state.defaultRepetitionRates];
      let targetIdx = defaultRepetitionRates.findIndex(o => o.id === drr.id);
      if (targetIdx !== -1) {
        defaultRepetitionRates[targetIdx] = drr;
      }
      let tmpTableTree: TableTree = {...state.tableTree};

      if (drr.tableId === TableId.SDT_ID) {
        tmpTableTree.sdtTables = updatedTables;
      }
      let idx = TableId.EIT_ALL_IDS.indexOf(drr.tableId);
      if (idx !== -1) {
        tmpTableTree.eitTablesMap = tmpTableTree.eitTablesMap.set(drr.tableId, updatedTables);
      }
      if (drr.tableId === TableId.NIT_ID) {
        tmpTableTree.nitNetworks = updatedTables;
      }
      if (drr.tableId === TableId.PRIVATE_TABLE_ID) {
        tmpTableTree.privateTables = updatedTables;
      }
      if (drr.tableId === TableId.TDT_ID) {
        tmpTableTree.tdtTables = updatedTables;
      }
      if (drr.tableId === TableId.PID32_ID) {
        tmpTableTree.pid32Tables = updatedTables;
      }
      if (drr.tableId === TableId.PMT_ID) {
        tmpTableTree.pmtTables = updatedTables;
      }
      if (drr.tableId === TableId.PAT_ID) {
        tmpTableTree.patTables = updatedTables;
      }
      if (drr.tableId === TableId.TOT_ID) {
        tmpTableTree.totTables = updatedTables;
      }
      return {
        ...state,
        isSaving: false,
        tableTree: tmpTableTree,
        defaultRepetitionRates: defaultRepetitionRates,
        messages: [{
          severity: 'success',
          summary: 'Updated ' + drr.tags[0] + ' export stream (tableId: ' + drr.tableId + ')',
          detail: 'Updated ' + drr.tags[0] + ' export stream (tableId: ' + drr.tableId + ') successfully',
        }]
      };
    }

    case
    exportStream.ActionTypes.SAVE_TABLE_SUCCESS
    :
      let tmpSdtTables: SdtTable[] = state.tableTree.sdtTables.concat();
      if (action.payload.type === TableTypes.SDT && tmpSdtTables) {
        let idx = tmpSdtTables.findIndex(sdt => sdt.id === action.payload.target.id);
        if (idx !== -1) {
          tmpSdtTables[idx] = action.payload.target
        }
      }
      let tmpNitTables: NitNetwork[] = state.tableTree.nitNetworks.concat();
      if (action.payload.type === TableTypes.NIT && tmpNitTables) {
        let idx = tmpNitTables.findIndex(nit => nit.id === action.payload.target.id);
        if (idx !== -1) {
          tmpNitTables[idx] = action.payload.target
        }
      }
      let tmpPrivateTables: PrivateTable[] = state.tableTree.privateTables.concat();
      if (action.payload.type === TableTypes.PRIVATE_TABLE && tmpPrivateTables) {
        let idx = tmpPrivateTables.findIndex(nit => nit.id === action.payload.target.id);
        if (idx !== -1) {
          tmpPrivateTables[idx] = action.payload.target
        }
      }
      let tmpTdtTables: Tdt[] = state.tableTree.tdtTables.concat();
      if (action.payload.type === TableTypes.TDT && tmpTdtTables) {
        let idx = tmpTdtTables.findIndex(tdt => tdt.id === action.payload.target.id);
        if (idx !== -1) {
          tmpTdtTables[idx] = action.payload.target
        }
      }
      let tmpPid32Tables: Pid32[] = state.tableTree.pid32Tables.concat();
      if (action.payload.type === TableTypes.PID32 && tmpPid32Tables) {
        let idx = tmpPid32Tables.findIndex(pid32 => pid32.id === action.payload.target.id);
        if (idx !== -1) {
          tmpPid32Tables[idx] = action.payload.target
        }
      }

      let tmpPmtTables: Pmt[] = [...state.tableTree.pmtTables];
      if (action.payload.type === TableTypes.PMT && tmpPmtTables) {
        let idx = tmpPmtTables.findIndex(pmt => pmt.id === action.payload.target.id);
        if (idx !== -1) {
          tmpPmtTables[idx] = action.payload.target
        }
      }
      let tmpPatTables: Pat[] = [...state.tableTree.patTables];
      if (action.payload.type === TableTypes.PAT && tmpPatTables) {
        let idx = tmpPatTables.findIndex(pat => pat.id === action.payload.target.id);
        if (idx !== -1) {
          tmpPatTables[idx] = action.payload.target
        }
      }
      let tmpTotTables: Tot[] = [...state.tableTree.totTables];
      if (action.payload.type === TableTypes.TOT && tmpTotTables) {
        let idx = tmpTotTables.findIndex(tot => tot.id === action.payload.target.id);
        if (idx !== -1) {
          tmpTotTables[idx] = action.payload.target
        }
      }

      let tmpEitTablesMap = state.tableTree.eitTablesMap;
      if (action.payload.type === TableTypes.EIT) {
        let currentEit: Eit = action.payload.target;
        let tmpEitTables = tmpEitTablesMap.get(currentEit.tableId) ? [...tmpEitTablesMap.get(currentEit.tableId)] : [];
        let idx = tmpEitTables.findIndex(eit => eit.id === currentEit.id && eit.tableId === currentEit.tableId);
        if (idx !== -1) {
          tmpEitTables[idx] = {
            ...action.payload.target,
            label: tmpEitTables[idx].label
          };
        }
        tmpEitTablesMap = tmpEitTablesMap.set(currentEit.tableId, tmpEitTables);
      }

      let tmpTableTree: TableTree = {
        ...state.tableTree,
        nitNetworks: tmpNitTables,
        sdtTables: tmpSdtTables,
        privateTables: tmpPrivateTables,
        tdtTables: tmpTdtTables,
        pid32Tables: tmpPid32Tables,
        eitTablesMap: tmpEitTablesMap,
        pmtTables: tmpPmtTables,
        patTables: tmpPatTables,
        totTables: tmpTotTables,
      };
      return {
        ...state,
        isSaving: false,
        tableTree: tmpTableTree,
        editingTable: action.payload,
        messages: [{
          severity: 'success',
          summary: 'Updated ' + action.payload.type,
          detail: 'Updated ' + action.payload.type + ' successfully',
        }]
      };

    case
    exportStream.ActionTypes.SAVE_TABLE_FAIL
    :
      return {
        ...state,
        isSaving: false,
        messages: [{
          severity: 'error',
          summary: 'Failed to save ' + action.payload.type,
          detail: 'Failed to perform action'
        }]
      };

    default:
      return state;
  }
}