Skip to content

Commit f112034

Browse files
authored
chore: fix types (#2679)
1 parent 89639ae commit f112034

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

packages/ui/components/core/test-helpers/getCachedFixture.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import { LitElement, nothing } from 'lit';
33
import { cache } from 'lit/directives/cache.js';
44
import { createRef } from 'lit/directives/ref.js';
55

6-
export async function getCachedFixture(render) {
6+
/**
7+
* Helper to get a fixture with a cached render function and show/hide methods.
8+
* @template T
9+
* @param {(ref: import('lit/directives/ref.js').Ref<T>) => import('lit').TemplateResult} render - The render function
10+
* @returns {Promise<{ wrapper: LitElement, el: T | undefined, show: () => Promise<void>, hide: () => Promise<void> }>}
11+
*/
12+
export async function getCachedFixture(
13+
/** @type {(ref: import('lit/directives/ref.js').Ref<any>) => import('lit').TemplateResult} */ render,
14+
) {
715
class CachingWrapper extends LitElement {
816
static properties = {
917
_show: { type: Boolean },
@@ -33,7 +41,10 @@ export async function getCachedFixture(render) {
3341
const customElementName = defineCE(CachingWrapper);
3442
const customTag = unsafeStatic(customElementName);
3543

36-
const wrapper = await fixture(html`<${customTag}></${customTag}>`);
44+
const wrapper =
45+
/** @type {LitElement & { ref: import('lit/directives/ref.js').Ref<any>, show(): Promise<void>, hide(): Promise<void> }} */ (
46+
await fixture(html`<${customTag}></${customTag}>`)
47+
);
3748

3849
return {
3950
wrapper,

packages/ui/components/listbox/test-suites/ListboxMixin.suite.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1792,10 +1792,13 @@ export function runListboxMixinSuite(customConfig = {}) {
17921792
});
17931793

17941794
it('does not calls "_onListboxContentChanged" during connect and disconnected', async () => {
1795-
const renderEl = refObj => html`<${wrappingTag} ${ref(refObj)}></${wrappingTag}>`;
1795+
const renderEl = /** @param {import('lit/directives/ref.js').Ref<any>} refObj */ refObj =>
1796+
html`<${wrappingTag} ${ref(refObj)}></${wrappingTag}>`;
17961797
const { el, show, hide } = await getCachedFixture(renderEl);
1797-
await el.listbox.registrationComplete;
1798-
const spy = sinon.spy(el.listbox, '_onListboxContentChanged');
1798+
const typedEl = /** @type {MyEl} */ (el);
1799+
await typedEl?.listbox.registrationComplete;
1800+
// @ts-ignore [allow-protected] in test
1801+
const spy = sinon.spy(typedEl.listbox, '_onListboxContentChanged');
17991802
await hide();
18001803
await show();
18011804

0 commit comments

Comments
 (0)