TypeScript Version: 3.1.0-dev.20180901
Search Terms: Readonly tuple
Code
type Foo = Readonly<[string, number]>;
const foo: Foo = ["hello", 42];
foo[0] = "blah";
Expected behavior:
Compile error at foo[0] = "blah" because the types of all indexes of the tuple should be readonly (this is the behavior in previous versions of Typescript, from at least 2.3 up to and including 3.0).
Actual behavior:
No compiler error. The type of foo is incorrectly reported as simply [string, number] rather than Readonly<[string, number]>, and the compiler allows the assignment.
TypeScript Version: 3.1.0-dev.20180901
Search Terms: Readonly tuple
Code
Expected behavior:
Compile error at
foo[0] = "blah"because the types of all indexes of the tuple should be readonly (this is the behavior in previous versions of Typescript, from at least 2.3 up to and including 3.0).Actual behavior:
No compiler error. The type of
foois incorrectly reported as simply[string, number]rather thanReadonly<[string, number]>, and the compiler allows the assignment.