-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsFix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.SuggestionAn idea for TypeScriptAn idea for TypeScript
Milestone
Description
Suggestion
π Search Terms
differing accessor types
β Viability 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, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
β Suggestion
#42425 forces the getter type to be assignable to the setter type. This makes the feature limited on the following DOM typing case, and thus it could be great if the limitation can be lifted.
π Motivating Example
[Exposed=Window]
interface CSSStyleRule : CSSRule {
attribute CSSOMString selectorText;
[SameObject, PutForwards=cssText] readonly attribute CSSStyleDeclaration style;
};
interface CSSStyleRule extends CSSRule {
selectorText: string;
get style(): CSSStyleDeclaration;
set style(cssText: string); // currently an error
}
document.body.style = "display: none" // thus still an error while the actual behavior allows it π€
π» Use Cases
Allows Web IDL readonly attributes to be assignable, and thus the DOM typing better matches the actual behavior.
Transferred from microsoft/TypeScript-DOM-lib-generator#996.
hopeless-programmer-online, kevinramharak, guilhermesimoes, whzx5byb, nkemcels and 47 morePentadome and jpidelatorreExE-Boss
Metadata
Metadata
Assignees
Labels
Experience EnhancementNoncontroversial enhancementsNoncontroversial enhancementsFix AvailableA PR has been opened for this issueA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.This issue needs a team member to investigate its status.SuggestionAn idea for TypeScriptAn idea for TypeScript