diff --git a/tests/baselines/reference/propertyAccessOfReadonlyIndexSignature.errors.txt b/tests/baselines/reference/propertyAccessOfReadonlyIndexSignature.errors.txt new file mode 100644 index 0000000000..8fa0624416 --- /dev/null +++ b/tests/baselines/reference/propertyAccessOfReadonlyIndexSignature.errors.txt @@ -0,0 +1,13 @@ +tests/cases/compiler/propertyAccessOfReadonlyIndexSignature.ts(6,1): error TS2542: Index signature in type 'Test' only permits reading. + + +==== tests/cases/compiler/propertyAccessOfReadonlyIndexSignature.ts (1 errors) ==== + interface Test { + readonly [key: string]: string; + } + + declare var a: Test; + a.foo = 'baz'; + ~~~~~ +!!! error TS2542: Index signature in type 'Test' only permits reading. + \ No newline at end of file diff --git a/tests/baselines/reference/propertyAccessOfReadonlyIndexSignature.js b/tests/baselines/reference/propertyAccessOfReadonlyIndexSignature.js new file mode 100644 index 0000000000..a1069eca55 --- /dev/null +++ b/tests/baselines/reference/propertyAccessOfReadonlyIndexSignature.js @@ -0,0 +1,11 @@ +//// [propertyAccessOfReadonlyIndexSignature.ts] +interface Test { + readonly [key: string]: string; +} + +declare var a: Test; +a.foo = 'baz'; + + +//// [propertyAccessOfReadonlyIndexSignature.js] +a.foo = 'baz'; diff --git a/tests/cases/compiler/propertyAccessOfReadonlyIndexSignature.ts b/tests/cases/compiler/propertyAccessOfReadonlyIndexSignature.ts new file mode 100644 index 0000000000..c5f28c5b09 --- /dev/null +++ b/tests/cases/compiler/propertyAccessOfReadonlyIndexSignature.ts @@ -0,0 +1,6 @@ +interface Test { + readonly [key: string]: string; +} + +declare var a: Test; +a.foo = 'baz';