prettier/tests/flow/multiflow_with_flowlib/spread.js

15 lines
701 B
JavaScript

declare var iterableOf123: Iterable<123>;
function fun(x: 'hi', y: 123) {}
fun('hi', ...iterableOf123); // No error - ignore the fact iterableOf123 could be empty
function funWithRestArray(x: 'hi', y: 123, ...rest: Array<number>) {}
funWithRestArray('hi', 123, ...iterableOf123); // Ok
funWithRestArray('hi', ...iterableOf123); // No error - ignore the fact iterableOf123 could be empty
funWithRestArray('hi', ...iterableOf123, ...iterableOf123); // No error - ignore the fact iterableOf123 could be empty
// 2 errors
// 1. 'bye' ~> 123 in case the first spread is empty
// 2. 'bye' ~> number in case the first spread is not empty
funWithRestArray('hi', ...iterableOf123, 'bye', ...iterableOf123);