Closed
Description
Examples:
// prefer-readonly-type flags this
// eslint-disable-next-line functional/prefer-readonly-type
const foo = new Array<string>();
// but not this
const bar = new Set<string>();
// nor this
const baz = new Map<string, string>();
And with explicit readonly type annotation:
// this readonly type annotation appeases prefer-readonly-type
const foo: readonly string[] = new Array<string>();
// so ideally these would too (if/when Set and Map are flagged)
const bar: ReadonlySet<string> = new Set<string>();
const baz: ReadonlyMap<string, string> = new Map<string, string>();
ReadonlySet
and ReadonlyMap
are built-in TypeScript types, but they don't enjoy special syntax support like arrays do (you can't say readonly Set<string>
, you must say ReadonlySet<string>
). For this reason I suspect this issue is a cousin to #150 and #51.