Closed as not planned
Closed as not planned
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Link to the rule's documentation
https://typescript-eslint.io/rules/array-type/
Description
A 4th option for the two property objects that would enforce array
for simple types and not enforce either syntax for other types. I like always using the clean []
syntax for simple types, but it's situational whether Array<>
is merited for more complex types - am I nesting multiple levels of array? Is it being used as a generic that already has lots of nested <>
?
Fail
const x: Array<string> = ['a', 'b'];
const y: ReadonlyArray<string> = ['a', 'b'];
const z: Array<MyType> = ['a', 'b'];
Pass
const x: string[] = ['a', 'b'];
const y: readonly string[] = ['a', 'b'];
const z: MyType[] = ['a', 'b'];
const a: (string | number)[] = ['a', 'b'];
const b: { prop: string }[] = [{ prop: 'a' }];
const c: (() => void)[] = [() => {}];
const d: Array<string | number> = ['a', 'b'];
const e: Array<{ prop: string }> = [{ prop: 'a' }];
const f: Array<() => void> = [() => {}];
Additional Info
I suggest the name array-simple-flex
, but any name is fine!