My Ttslint throws a warning with this construction (Array type using Array is forbidden. Use T[] instead (array-type) ):
Array<string | null> | null
Is this correct replacement to the previous one?
(string | null)[] | null
Yes, that is the behavior that the array-type rule enforces, when it is set to "array"
:
One of the following arguments must be provided:
*"array"
enforces use ofT[]
for all typesT
.
*"generic"
enforces use of Array for all typesT
.
*"array-simple"
enforces use ofT[]
ifT
is a simple type (primitive or type reference).
You can disable the rule for the entire file by creating a tslint.json
file in the same folder as the file (or in a parent folder of the file) and writing the following inside it:
"rules": {
"array-type": false
}
If you want to choose one of the other settings:
"rules": {
"array-type": [true, "generic"]
}
And, as you've mentioned in your question, the equivalent for:
Array<string | null> | null
is:
(string | null)[] | null
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With