-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureFixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript
Description
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.
forivall, ulrichb, miyaokamarina and jonaskello
Metadata
Metadata
Assignees
Labels
Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureThis means we'd like to hear from more people who would be helped by this featureFixedA PR has been merged for this issueA PR has been merged for this issueSuggestionAn idea for TypeScriptAn idea for TypeScript