Skip to content

Commit

Permalink
fix(element): handle typescript limitation about protected mixin prop…
Browse files Browse the repository at this point in the history
…erty
  • Loading branch information
njfamirm committed Dec 7, 2024
1 parent 24de303 commit ad2adea
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/element/src/mixin/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ export function LoggerMixin<T extends Class<LitElement> = Class<LitElement>>(
superClass: T,
): Class<LoggerMixinInterface> & T {
return class MixinClass extends superClass {
// Unique index for each element instance
/**
* Unique index for each element instance.
*/
private elementIndex__: number = ++elementIndex;

// Logger instance with a tag name and unique index
/**
* Logger instance with a tag name and unique index.
*/
protected logger_ = createLogger(`<${this.tagName.toLowerCase()}-${this.elementIndex__}>`);

private firstUpdated__?: true;
Expand Down Expand Up @@ -105,5 +109,5 @@ export function LoggerMixin<T extends Class<LitElement> = Class<LitElement>>(
this.logger_.logMethod?.('remove');
super.remove();
}
} as unknown as Class<LoggerMixinInterface> & T;
} as unknown as Class<LoggerMixinInterface> & T; // Typescript Don't support protected mixin methods!
}

0 comments on commit ad2adea

Please sign in to comment.