As discussed here, we want to convert all Array signatures to [] in the k6-browser docs.
It is common to use simple array types in typescript, i.e. Cookie[], for named types:
let a: string[]
let b: boolean[]
let c: SomeInterface[]
The generic version is usually reserved for more complex types, where the brackets might be easy to miss due to the amount of symbols:
let a1: Promise<({ prop: boolean })[]>
// vs.
let a2: Promise<Array<{ prop: boolean }>>
let b1: Promise<(typeof myVal)[]>
// vs.
let b2: Promise<Array<typeof myVal>>
Ups
Promise<Inner[]> is easier to read than Promise<Array<Inner>>. The eye does not need to match opening and closing braces.
The bracket syntax is ubiquitous in programming, whereas generics are an advanced feature and the syntax is more varied.
Downs
Slightly mismatching with PW (i.e., see this). However, improved readability outweighs being consistent with PW's docs. It also appears to be a convention we've used in the type definitions.
As discussed here, we want to convert all
Array
signatures to[]
in the k6-browser docs.It is common to use simple array types in typescript, i.e.
Cookie[]
, for named types:The generic version is usually reserved for more complex types, where the brackets might be easy to miss due to the amount of symbols:
Ups
Promise<Inner[]>
is easier to read thanPromise<Array<Inner>>
. The eye does not need to match opening and closing braces.Downs