mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Test:property access respects readonly index signature
This commit is contained in:
@@ -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';
|
||||
Reference in New Issue
Block a user