What's the syntax to have this import in a normal JavaScript file and have it work with JSDoc (tsc)?
What I've tried
/** @import('typed-query-selector/strict') */ // doesn't seem to update the types
/** @import type {} from 'typed-query-selector/strict' */ // E: 'from' expected.
Problem
let $input = $("input");
if (!$input) {
throw new Error("no input selected");
}
f.value = "foo"; // E: Property 'value' does not exist on type 'Element'.
Sample Code
Here's how I'm trying to use it, in full:
/** @import('typed-query-selector/strict') */
/**
* Select first matching element, just like console $
* @param {String} cssSelector
* @param {ParentNode} [$parent=document]
*/
function $(cssSelector, $parent = document) {
let $child = $parent.querySelector(cssSelector);
return $child;
}
/**
* Select all matching child elements as a JS Array, just like console $$
* @param {String} cssSelector
* @param {ParentNode} [$parent=document]
*/
function $$(cssSelector, $parent = document) {
let $children = $parent.querySelectorAll(cssSelector);
let children = Array.from($children);
return children;
}
What's the syntax to have this import in a normal JavaScript file and have it work with JSDoc (tsc)?
What I've tried
Problem
Sample Code
Here's how I'm trying to use it, in full: