LWC Typescript definitions inaccurate

Issue #1711 new
Xander Victory created an issue

In a recent update, it seems you added the missing NodeSelector interface, but the methods are marked as having no parameters (which they certainly do), leading to “Invalid number of arguments, expected 0”

In my custom LWC typings version I have the definition: (copied from IDEA’s es7 module if my comment is to be believed)

interface NodeSelector {
    querySelector<E extends Element = Element>(selectors: string): E | null;
    querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;

The navigation module is also quite wrong.

It should be more like:

const Navigate: unique symbol = Symbol('Navigate');
const GenerateUrl: unique symbol = Symbol('GenerateUrl');

declare module "lightning/navigation" {
    /** use with @wire, but directly assigns the pageref, not {data,error} */
    function CurrentPageReference(config?: any): any;

    const NavigationMixin: {
        <T>(Base: T): T & NavClz
        readonly Navigate: typeof Navigate
        readonly GenerateUrl: typeof GenerateUrl

    class NavClz {
        [NavigationMixin.Navigate](pageReference: PageReference, replace?: boolean): void;
        [NavigationMixin.GenerateUrl](pageReference: PageReference): Promise<string>;

    interface PageReference {
        type: PageRefType;
        attributes?: object;
        state: {
            [key: string]: string;

    type PageRefType = 'standard__app' |
                       'standard__component' |
                       'comm__loginPage' |
                       'standard__knowledgeArticlePage' |
                       'comm__namedPage' |
                       'standard__namedPage' |
                       'standard__navItemPage' |
                       'standard__objectPage' |
                       'standard__recordPage' |
                       'standard__recordRelationshipPage' |

I’m working on better page reference autocompletion, but this definition has served me well so far.

Comments (2)

  1. Scott Wells repo owner

    Hi, Xander. Good to know. The NodeSelector one is from my own implementation. The other stuff is straight from the TS modules provided by Salesforce. I'll look into improving them. Thanks for the details!

  2. Log in to comment