-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Default to ReadonlyArray #32467
Copy link
Copy link
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 featureSuggestionAn idea for TypeScriptAn idea for TypeScript
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 featureSuggestionAn idea for TypeScriptAn idea for TypeScript
Search Terms
ReadonlyArray, default
Suggestion
By default type for array is inferred as
Array. It would be better to default to a more strictReadonlyArrayand if programmer needs mutability — he would explicitly state so. Could be atsconfigoption to not introduce a breaking change.Use Cases
readonly value = [0, 1, 2, 3]; // <-- type number[] hereExamples
Checklist
My suggestion meets these guidelines: