Test:property access respects readonly index signature
This commit is contained in:
parent
50b2b77f44
commit
85c10320db
|
@ -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.
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
//// [propertyAccessOfReadonlyIndexSignature.ts]
|
||||
interface Test {
|
||||
readonly [key: string]: string;
|
||||
}
|
||||
|
||||
declare var a: Test;
|
||||
a.foo = 'baz';
|
||||
|
||||
|
||||
//// [propertyAccessOfReadonlyIndexSignature.js]
|
||||
a.foo = 'baz';
|
|
@ -0,0 +1,6 @@
|
|||
interface Test {
|
||||
readonly [key: string]: string;
|
||||
}
|
||||
|
||||
declare var a: Test;
|
||||
a.foo = 'baz';
|
Loading…
Reference in a new issue