diff --git a/packages/type-utils/tests/isTypeReadonly.test.ts b/packages/type-utils/tests/isTypeReadonly.test.ts index 7153b44d7769..7f806c830e0a 100644 --- a/packages/type-utils/tests/isTypeReadonly.test.ts +++ b/packages/type-utils/tests/isTypeReadonly.test.ts @@ -215,5 +215,31 @@ describe('isTypeReadonly', () => { }); }); }); + + describe('IndexSignature', () => { + describe('is readonly', () => { + it('handles readonly PropertySignature inside a readonly IndexSignature', () => { + const { type, checker } = getType( + `type Test = { readonly [key: string]: { readonly foo: readonly string[]; }; };`, + ); + + const result = isTypeReadonly(checker, type); + expect(result).toBe(true); + }); + }); + + describe('is not readonly', () => { + describe('default options', () => { + it('fails with a mutable PropertySignature inside a readonly IndexSignature', () => { + const { type, checker } = getType( + `type Test = { readonly [key: string]: { foo: string[]; }; };`, + ); + + const result = isTypeReadonly(checker, type); + expect(result).toBe(false); + }); + }); + }); + }); }); });