Adding onto
Blockquote
Adding onto this answer, I had hex strings in the form '#DDDDDD' which required some type wrangling
const hex: number = parseInt(color.slice(-6), 16);
const complement = 0xffffff ^ hex;
const hexColor = '#' + ('000000' + complement.toString(16)).slice(-6);