Salesforce and JavaScript community!
I'm looking for the best way to type the result of a querySelectorAll call that targets custom LWC elements. My query is specifically aimed at selecting lightning-input and lightning-input-field components within a form, like so:
const input = form.querySelector("lightning-input");
The only workable option I've found so far is to make my own LightningInput.d.ts
type to capture the custom params and actions uniquely available to a LWC.
Questions:
- Is there a way to use JSDoc to more accurately type the result of querySelectorAll when targeting specific Salesforce LWC components without resorting to custom type definitions?
- If custom types are the only solution, what would be the best practice for defining these types to include the specific properties or methods of the LWC components mentioned?
ObjectInfoRepresentation
(i.e. the return type of the uiApi's getObjectInfo function)