While the statement may hold true for a short period of time any employer who knows what they are doing will resist "islands of knowledge" and will force you to train other people in your task which may eventually lead to your termination.
From a personal perspective do you always want to be doing the same work on the same project/area day in/day out for the next 40 years, be contactable even on holidays when something goes bump in night?
Having worked in IT for 17+ years in various jobs/roles I have yet to meet someone who cannot be replaced (if got killed crossing the road the company would still go oon!). Yes sometimes there is a productivity drop when the "irreplacable" person leaves but after a few weeks its like they were never there and in some cases productivity is even better.
You would be far better to become an expert in several areas covering coding, business process, design and become the "go to" person for anyone who has questions in your company. Being the "go to" person doesn't mean you have all the answers but that you have enough experience/contacts to have the answer or to very quickly find the person who does.
In my experience companies prefer these types of people rather then someone who thinks they are "irreplacable" for a particular function.
If though your field is an extremely specialised such as heart surgery and you are a world expert then maybe you might just be "irreplacable".