This is a follow-up to #52111 and #52123.
In the below code, every works as expected, which is new as of #52123. However, the some function can't be called on the array type at all, even though reasonably there's a top type which works (A), just like it works for every.
interfaceA{a: string;}interfaceBextendsA{b: string;}interfaceCextendsA{c: string;}declarefunctionisC(x: A): x is C;declarefunctionevery<T,UextendsT>(array: readonlyT[],callback: (element: T,index: number)=>element is U): array is readonlyU[];declarefunctionevery<T,UextendsT>(array: readonlyT[]|undefined,callback: (element: T,index: number)=>element is U): array is readonlyU[]|undefined;declarefunctionevery<T>(array: readonlyT[]|undefined,callback: (element: T,index: number)=>boolean): boolean;declarefunctionsome<T>(array: readonlyT[]|undefined): array is readonlyT[];declarefunctionsome<T>(array: readonlyT[]|undefined,predicate: (value: T)=>boolean): boolean;functionfoo(array: readonlyB[]|readonlyC[]|undefined){if(every(array,isC)){array;// ^?}if(some(array)){array;// ^?}if(some(array,isC)){array;// ^?}if(some<A>(array)){array;// ^?}if(some<A>(array,isC)){array;// ^?}}Output
"use strict";functionfoo(array){if(every(array,isC)){array;// ^?}if(some(array)){array;// ^?}if(some(array,isC)){array;// ^?}if(some(array)){array;// ^?}if(some(array,isC)){array;// ^?}}Compiler Options
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"esModuleInterop": true,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"target": "ES2017",
"jsx": "react",
"module": "ESNext",
"moduleResolution": "node"
}
}Playground Link:Provided
This is a follow-up to #52111 and #52123.
In the below code,
everyworks as expected, which is new as of #52123. However, thesomefunction can't be called on the array type at all, even though reasonably there's a top type which works (A), just like it works forevery.Output
Compiler Options
{ "compilerOptions": { "strict": true, "noImplicitAny": true, "strictNullChecks": true, "strictFunctionTypes": true, "strictPropertyInitialization": true, "strictBindCallApply": true, "noImplicitThis": true, "noImplicitReturns": true, "alwaysStrict": true, "esModuleInterop": true, "declaration": true, "experimentalDecorators": true, "emitDecoratorMetadata": true, "target": "ES2017", "jsx": "react", "module": "ESNext", "moduleResolution": "node" } }Playground Link:Provided