This should be triple equals

    if (type === 'merge') {

(same goes for the next if case)