-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(expansion): enforce stricter types for inputs #20287
fix(expansion): enforce stricter types for inputs #20287
Conversation
e88e221
to
eaaa368
Compare
baaaf36
to
8d75ba1
Compare
set disabled(disabled: any) { this._disabled = coerceBooleanProperty(disabled); } | ||
private _disabled: boolean = false; | ||
get disabled(): boolean { return this._disabled; } | ||
set disabled(disabled: boolean) { this._disabled = coerceBooleanProperty(disabled); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The whole point of using coercion here is that you can pass in anything. The problem is that TS doesn't support different types for the getter and the setter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I know. And I'm aware this is a breaking change and I wouldn't expect it to be merged until you reach v11 stages.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we were actually requiring these to be boolean, the coerceBooleanProperty
call becomes redundant. I think that changing this defeats the purpose and we'd have to do it across the entire codebase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do actually use boolean for all boolean accessors, these here modified in this PR are outside the rule. It helps not only documentation, but the dev experience when accessing a getter, for example, you'd want a boolean
, not any
.
See these two examples for reference:
components/src/material/expansion/expansion-panel.ts
Lines 107 to 113 in cb8de61
@Input() | |
get hideToggle(): boolean { | |
return this._hideToggle || (this.accordion && this.accordion.hideToggle); | |
} | |
set hideToggle(value: boolean) { | |
this._hideToggle = coerceBooleanProperty(value); | |
} |
components/src/cdk/drag-drop/directives/drop-list-group.ts
Lines 36 to 41 in cfe37d1
@Input('cdkDropListGroupDisabled') | |
get disabled(): boolean { return this._disabled; } | |
set disabled(value: boolean) { | |
this._disabled = coerceBooleanProperty(value); | |
} | |
private _disabled = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM- we'll find out how breaking this is inside Google once we get closer to v11
Caretaker note: Don't merge until v11 release train |
@rafaelss95 could you add a "BREAKING CHANGE" note to the commit message? |
89e3e9a
to
5fe3def
Compare
Let me know if it's fine now. |
5fe3def
to
7b3a797
Compare
@rafaelss95 just checked- the commit has to be a |
7b3a797
to
5d3367f
Compare
@jelbourn It should be ok now. |
a45e3dd
to
b30b1eb
Compare
BREAKING CHANGE: The `disabled` and `expanded` properties in the `AccordionItem` are now strict to `boolean`.
b30b1eb
to
e04e5d2
Compare
@annieyw is there any chance to merge this before v12? :) |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
No description provided.