Skip to content

Commit 9a9b8e6

Browse files
committed
add types for sync directive
1 parent ba51028 commit 9a9b8e6

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export { LitNotify } from './notify';
2+
export { LitSync } from './sync';

sync.d.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { LitElement, UpdatingElement } from 'lit-element';
2+
3+
type Constructor<T = LitElement> = new (...args: any[]) => T;
4+
5+
declare class SyncElement {
6+
sync(property: string, eventName?: string): void
7+
}
8+
9+
export function LitSync<T extends UpdatingElement>(baseElement: Constructor<T>): T & SyncElement

sync.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import {directive} from "lit-html/lib/directive.js";
22
import {eventNameForProperty} from "./notify.js";
33

4+
// eslint-disable-next-line valid-jsdoc
45
/**
56
* Mixin that provides a lit-html directive to sync a property to a child property
67
*
7-
* @param {LitElement} baseElement - the LitElement to extend
8+
* @template TBase
9+
* @param {Constructor<TBase>} baseElement
810
*/
911
export const LitSync = (baseElement) => class extends baseElement {
1012
constructor() {

0 commit comments

Comments
 (0)