Skip to content

Commit de7f7b1

Browse files
authoredNov 5, 2021
fix(testing-helpers): ts types (#2345)
Create spotty-swans-mate.md chore: lint files
1 parent 5a28b1a commit de7f7b1

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed
 

Diff for: ‎.changeset/spotty-swans-mate.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@open-wc/testing-helpers': patch
3+
'@open-wc/testing': patch
4+
---
5+
6+
Fix the typescript typings in testing helpers for projects that depend on `lit` package

Diff for: ‎packages/testing-helpers/src/fixture-no-side-effect.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { isValidRenderArg } from './lib.js';
1616
* const el = fixtureSync('<my-el><span></span></my-el>');
1717
*
1818
* @template {Element} T
19-
* @param {import('./litFixture').LitHTMLRenderable} template Either a string or lit-html TemplateResult
19+
* @param {import('./renderable').LitHTMLRenderable} template Either a string or lit-html TemplateResult
2020
* @param {FixtureOptions} [options]
2121
* @returns {T} First child of the rendered DOM
2222
*/
@@ -49,7 +49,7 @@ export function fixtureSync(template, options) {
4949
* expect(el.fullyRendered).to.be.true;
5050
*
5151
* @template {Element} T
52-
* @param {import('./litFixture').LitHTMLRenderable} template Either a string or lit-html TemplateResult
52+
* @param {import('./renderable').LitHTMLRenderable} template Either a string or lit-html TemplateResult
5353
* @param {FixtureOptions} [options]
5454
* @returns {Promise<T>} A Promise that will resolve to the first child of the rendered DOM
5555
*/

Diff for: ‎packages/testing-helpers/src/litFixture.js

+2-13
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,6 @@ import { fixtureWrapper } from './fixtureWrapper.js';
44
import { elementUpdated } from './elementUpdated.js';
55
import { NODE_TYPES } from './lib.js';
66

7-
/**
8-
* @typedef {
9-
import('lit').TemplateResult
10-
| import('lit').TemplateResult[]
11-
| Node | Node[]
12-
| string | string[]
13-
| number | number[]
14-
| boolean | boolean[]
15-
} LitHTMLRenderable
16-
*/
17-
187
const isUsefulNode = ({ nodeType, textContent }) => {
198
switch (nodeType) {
209
case NODE_TYPES.COMMENT_NODE:
@@ -30,7 +19,7 @@ const isUsefulNode = ({ nodeType, textContent }) => {
3019
* Setups an element synchronously from the provided lit-html template and puts it in the DOM.
3120
*
3221
* @template {Element} T - Is an element or a node
33-
* @param {LitHTMLRenderable} template
22+
* @param {import('./renderable').LitHTMLRenderable} template
3423
* @param {import('./fixture-no-side-effect.js').FixtureOptions} [options]
3524
* @param {import('./scopedElementsWrapper.js').ScopedElementsTemplateGetter} [getScopedElementsTemplate]
3625
* @returns {T}
@@ -55,7 +44,7 @@ export function litFixtureSync(template, options = {}, getScopedElementsTemplate
5544
* Setups an element asynchronously from the provided lit-html template and puts it in the DOM.
5645
*
5746
* @template {Element} T - Is an element or a node
58-
* @param {LitHTMLRenderable} template
47+
* @param {import('./renderable').LitHTMLRenderable} template
5948
* @param {import('./fixture-no-side-effect.js').FixtureOptions} [options]
6049
* @returns {Promise<T>}
6150
*/

Diff for: ‎packages/testing-helpers/src/renderable.ts

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { TemplateResult } from 'lit';
2+
3+
export type LitHTMLRenderable = (
4+
TemplateResult
5+
| TemplateResult[]
6+
| Node | Node[]
7+
| string | string[]
8+
| number | number[]
9+
| boolean | boolean[]
10+
);
11+
12+
export {};

Diff for: ‎packages/testing-helpers/src/scopedElementsWrapper.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ScopedElementsTestWrapper extends ScopedElementsMixin(LitElement) {
3232
/** @type {ScopedElementsMap} */
3333
this.scopedElements = {};
3434

35-
/** @type {import('./litFixture').LitHTMLRenderable} */
35+
/** @type {import('./renderable').LitHTMLRenderable} */
3636
// eslint-disable-next-line no-unused-expressions
3737
this.template;
3838
}
@@ -69,7 +69,7 @@ const getWrapperUniqueName = (counter = 0) => {
6969
/**
7070
* Wraps the template inside a scopedElements component
7171
*
72-
* @param {import('./litFixture').LitHTMLRenderable} template
72+
* @param {import('./renderable').LitHTMLRenderable} template
7373
* @param {ScopedElementsMap} scopedElements
7474
* @return {TemplateResult}
7575
*/

0 commit comments

Comments
 (0)
Please sign in to comment.