TypeScript/tests/cases/compiler/arrayEvery.ts
Dmitri 0bc29acc08
Add a type-guard overload of Array.every (#38200)
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-06-17 13:02:30 -07:00

8 lines
168 B
TypeScript

const foo: (number | string)[] = ['aaa'];
const isString = (x: unknown): x is string => typeof x === 'string';
if (foo.every(isString)) {
foo[0].slice(0);
}