Skip to content

Commit

Permalink
chore(decorators): update key types for ariaProperty
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 460552893
  • Loading branch information
asyncLiz authored and copybara-github committed Jul 12, 2022
1 parent 0949b07 commit 42bf876
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions decorators/aria-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ import {ReactiveElement} from 'lit';
* @category Decorator
* @ExportDecoratedItems
*/
export function ariaProperty(
prototype: ReactiveElement, property: keyof ARIAMixin) {
export function ariaProperty<E extends ReactiveElement, K extends keyof E&
`aria${string}`>(prototype: E, property: K) {
// Replace the ARIAMixin property with data-* attribute syncing instead of
// using the native aria-* attribute reflection. This preserves the attribute
// for SSR and avoids screenreader conflicts after delegating the attribute
Expand Down Expand Up @@ -75,9 +75,9 @@ export function ariaProperty(
// tslint is failing here, but the types are correct (ARIAMixin
// properties do not obfuscate with closure)
// tslint:disable-next-line:no-dict-access-on-struct-type
return this[property];
return (this as E)[property];
},
set(this: ReactiveElement, value: string) {
set(this: ReactiveElement, value: E[K]) {
if (removingAttribute) {
// Ignore this update, which is triggered below
return;
Expand All @@ -88,7 +88,7 @@ export function ariaProperty(
// tslint is failing here, but the types are correct (ARIAMixin
// properties do not obfuscate with closure)
// tslint:disable-next-line:no-dict-access-on-struct-type
this[property] = value;
(this as E)[property] = value;
// Remove the `aria-*` attribute, which will call this setter again with
// the incorrect value. Ignore these updates.
removingAttribute = true;
Expand Down

0 comments on commit 42bf876

Please sign in to comment.