harden 'get import declaration' logic