⚙ Compilation target
es5
⚙ Library
es5
Missing / Incorrect Definition
some in lib.es5.d.ts could be defined as follows (return type from boolean to this is [T, ...T[]]):
interface Array<T> {
some(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): this is [T, ...T[]];
}
Sample Code
playground
function requiresOneItem<T>(array: [T, ...T[]]) {}
function isFoo<T>(item: T) { return true }
const array = [1, 2]
if (array.some(isFoo)) {
requiresOneItem(array) // Argument of type 'number[]' is not assignable to parameter of type '[number, ...number[]]'.
}
interface Array<T> {
// Uncomment to test:
// some(predicate: (value: T, index: number, array: T[]) => unknown, thisArg?: any): this is [T, ...T[]];
}
Documentation Link
N.A. Calling .some() on an array can only ever return true if the array is not empty.
⚙ Compilation target
es5
⚙ Library
es5
Missing / Incorrect Definition
someinlib.es5.d.tscould be defined as follows (return type frombooleantothis is [T, ...T[]]):Sample Code
playground
Documentation Link
N.A. Calling
.some()on an array can only ever return true if the array is not empty.