public verifyRangesAreRenameLocations(options?: Range[] | { findInStrings?: boolean, findInComments?: boolean, ranges?: Range[] }) {
const ranges = ts.isArray(options) ? options : options && options.ranges || this.getRanges();
this.verifyRenameLocations(ranges, { ranges, ...options });
}
When options is a Range[], the object spread creates an object that is like an array, except without its methods, and with a property named ranges that is the array itself. This works fine because of the way that verifyRenameLocations uses ts.isArray (the spread object never is), but should probably be something more like:
const ranges = ts.isArray(options) ? options : options.ranges || this.getRanges();
this.verifyRenameLocations(ranges, ts.isArray(options) ? options : { ranges, ...options });
Found while working on excess property checks, although this usage is not actually an error in the PR.
When
optionsis aRange[], the object spread creates an object that is like an array, except without its methods, and with a property namedrangesthat is the array itself. This works fine because of the way thatverifyRenameLocationsusests.isArray(the spread object never is), but should probably be something more like:Found while working on excess property checks, although this usage is not actually an error in the PR.