Replies: 5 comments
-
You can use |
Beta Was this translation helpful? Give feedback.
-
Where are you trying that code? What’s your code editor? |
Beta Was this translation helpful? Give feedback.
-
@fregante I'm using vim-ale, tsc, and jswt. The project I'm working on today is just a parody project, but I use it as boilerplate for real projects: You can see the jsconfig and whatnot here: https://github.com/coolaj86/ajquery.js It should work in any editor. There's no special editor-specific config. |
Beta Was this translation helpful? Give feedback.
-
Copying this here from #43, since this is actually more related to this issue (documentation for how to use this as-is) than that one (request to add $ as a global export): This is the sort of thing I would expect to be able to do: Option A: Apply the type directly to the function: /** @typedef {@import("typed-query-selector/strict").RelativeSelectorCallbackDefinition} RelativeSelector */
/** @typedef {@import("typed-query-selector/strict").RelativeSelectorAllCallbackDefinition} RelativeSelectorAll */
/** @type {RelativeSelector} */
const $ = (s, e = document) => e.querySelector(s)
/** @type {RelativeSelectorAll} */
const $$ = (s, e = document) => Array.from(e.querySelectorAll(s)) Option B: Apply the return type: /** @typedef {@import("typed-query-selector/strict").AmbiElement} AmbiElement */
/** @typedef {@import("typed-query-selector/strict").AmbiElement} AmbiElement */
/**
* @param {String} s
* @param {ParentNode} e
* @returns {AmbiElement}
*/
const $ = (s, e = document) => e.querySelector(s)
/**
* @param {String} s
* @param {ParentNode} e
* @returns {Array<AmbiElement>}
*/
const $$ = (s, e = document) => Array.from(e.querySelectorAll(s)) |
Beta Was this translation helpful? Give feedback.
-
You might want to ask StackOverflow on how to do this |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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:
Beta Was this translation helpful? Give feedback.
All reactions