feat: add types + linting & improve intellisense

This commit is contained in:
Thomas Allmer
2019-03-09 19:05:57 +01:00
parent 02c05aefee
commit b6d260c04f
49 changed files with 374 additions and 168 deletions

View File

@@ -5,21 +5,23 @@ import { elementUpdated } from './elementUpdated.js';
* Setups an element synchronously from the provided string template and puts it in the DOM.
* Allows to specify properties via an object or a function taking the element as an argument.
*
* @template {Element} T - Is an element or a node
* @param {string} template
* @returns {Element}
* @returns {T}
*/
export function stringFixtureSync(template) {
const wrapper = fixtureWrapper();
wrapper.innerHTML = template;
return wrapper.children[0];
return /** @type {T} */ (wrapper.children[0]);
}
/**
* Setups an element asynchronously from the provided string template and puts it in the DOM.
* Allows to specify properties via an object or a function taking the element as an argument.
*
* @template {Element} T - Is an element or a node
* @param {string} template
* @returns {Promise<Element>}
* @returns {Promise<T>}
*/
export async function stringFixture(template) {
const el = stringFixtureSync(template);