Difference between type[] and [type] in typescript
-
[string]
denotes aTuple
of type string -
string[]
denotes an array of strings
The correct usage of the Tuple in your case would be:
let type2:WithStringArray2 = {
property: ['someString']
};
See Documentation
if we look tuple with three variable. you can see the difference clearly.
let t: [number, string?, boolean?];
t = [42, "hello", true];
let tuple : [string]
is tuple(string) whereas let arr : string[]
is array of string.