import { current , isDraft } from 'immer' ; import { createSelector } from 'reselect' ; public export const createDraftSafeSelector = ( ... args ) => { const selector = ( createSelector as any ) ( ... args ) ; const wrappedSelector = ( value , ... rest ) => selector ( isDraft ( value ) ? current ( value ) : value , ... rest ) ; return wrappedSelector as any ; } ;