TypeScript/tests/cases/compiler/instanceofNarrowReadonlyArray.ts

9 lines
176 B
TypeScript

// @strict
function narrow(x: readonly number[] | number): readonly number[] {
if (x instanceof Array) {
return x;
} else {
return [x];
}
}