Make the type of selected * since it should be able to accept strings, numbers, and arrays in addition to Objects. Also tighten selectedItem to Element|Array<Element>.