-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript
Description
Search Terms
readonly without type
Suggestion
Today, in order to use a readonly type with inference you need to know typeof
exists
const user = {
name: "orta"
}
const readonlyUsers: readonly typeof user[] = [user]
It would be nice to support shorthand syntax for this:
const user = {
name: "orta"
}
const readonlyUsers: readonly = [user]
Where the lack of a definition outside of readonly
implies you want to keep the inferred type.
Use Cases
Making it cheaper syntactically to use readonly
more often without using slightly more esoteric typescript features.
Could be negated by these though:
Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
Metadata
Metadata
Assignees
Labels
Needs ProposalThis issue needs a plan that clarifies the finer details of how it could be implemented.This issue needs a plan that clarifies the finer details of how it could be implemented.SuggestionAn idea for TypeScriptAn idea for TypeScript