Test:property access respects readonly index signature

This commit is contained in:
Nathan Shively-Sanders 2017-08-09 16:16:28 -07:00
parent 50b2b77f44
commit 85c10320db
3 changed files with 30 additions and 0 deletions

View file

@ -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.

View file

@ -0,0 +1,11 @@
//// [propertyAccessOfReadonlyIndexSignature.ts]
interface Test {
readonly [key: string]: string;
}
declare var a: Test;
a.foo = 'baz';
//// [propertyAccessOfReadonlyIndexSignature.js]
a.foo = 'baz';

View file

@ -0,0 +1,6 @@
interface Test {
readonly [key: string]: string;
}
declare var a: Test;
a.foo = 'baz';