UNPKG

6.03 kBTypeScriptView Raw
1/*
2 * Copyright (c) 2018, salesforce.com, inc.
3 * All rights reserved.
4 * SPDX-License-Identifier: MIT
5 * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
6 */
7/**
8 * Lightning Web Components core module
9 */
10declare module 'lwc' {
11 // backwards compatible type used for the old days when TS didn't support `event.composed`
12 interface ComposableEvent extends Event {
13 composed: boolean;
14 }
15
16 class HTMLElementTheGoodPart {
17 dispatchEvent(evt: Event): boolean;
18 addEventListener(
19 type: string,
20 listener: EventListenerOrEventListenerObject,
21 options?: boolean | AddEventListenerOptions
22 ): void;
23 removeEventListener(
24 type: string,
25 listener: EventListenerOrEventListenerObject,
26 options?: boolean | EventListenerOptions
27 ): void;
28 setAttributeNS(ns: string, attrName: string, value: any): void;
29 removeAttributeNS(ns: string, attrName: string): void;
30 removeAttribute(attrName: string): void;
31 setAttribute(attrName: string, value: any): void;
32 getAttribute(attrName: string): string | null;
33 getAttributeNS(ns: string, attrName: string): string | null;
34 getBoundingClientRect(): ClientRect;
35 querySelector<E extends Element = Element>(selectors: string): E | null;
36 querySelectorAll<E extends Element = Element>(selectors: string): NodeListOf<E>;
37 getElementsByTagName(tagNameOrWildCard: string): HTMLCollectionOf<Element>;
38 getElementsByClassName(names: string): HTMLCollectionOf<Element>;
39 readonly tagName: string;
40 readonly classList: DOMTokenList;
41
42 // Default HTML Properties
43 dir: string;
44 id: string;
45 accessKey: string;
46 title: string;
47 lang: string;
48 hidden: boolean;
49 draggable: boolean;
50 tabIndex: number;
51
52 // Aria Properties
53 ariaAutoComplete: string | null;
54 ariaChecked: string | null;
55 ariaCurrent: string | null;
56 ariaDisabled: string | null;
57 ariaExpanded: string | null;
58 ariaHasPopup: string | null;
59 ariaHidden: string | null;
60 ariaInvalid: string | null;
61 ariaLabel: string | null;
62 ariaLevel: string | null;
63 ariaMultiLine: string | null;
64 ariaMultiSelectable: string | null;
65 ariaOrientation: string | null;
66 ariaPressed: string | null;
67 ariaReadOnly: string | null;
68 ariaRequired: string | null;
69 ariaSelected: string | null;
70 ariaSort: string | null;
71 ariaValueMax: string | null;
72 ariaValueMin: string | null;
73 ariaValueNow: string | null;
74 ariaValueText: string | null;
75 ariaLive: string | null;
76 ariaRelevant: string | null;
77 ariaAtomic: string | null;
78 ariaBusy: string | null;
79 ariaActiveDescendant: string | null;
80 ariaControls: string | null;
81 ariaDescribedBy: string | null;
82 ariaFlowTo: string | null;
83 ariaLabelledBy: string | null;
84 ariaOwns: string | null;
85 ariaPosInSet: string | null;
86 ariaSetSize: string | null;
87 ariaColCount: string | null;
88 ariaColIndex: string | null;
89 ariaDetails: string | null;
90 ariaErrorMessage: string | null;
91 ariaKeyShortcuts: string | null;
92 ariaModal: string | null;
93 ariaPlaceholder: string | null;
94 ariaRoleDescription: string | null;
95 ariaRowCount: string | null;
96 ariaRowIndex: string | null;
97 ariaRowSpan: string | null;
98 ariaColSpan: string | null;
99 role: string | null;
100 }
101
102 // @ts-ignore type-mismatch
103 interface ShadowRootTheGoodPart extends NodeSelector {
104 mode: string;
105 readonly activeElement: Element | null;
106 readonly host: HTMLElement;
107 readonly firstChild: Node | null;
108 readonly lastChild: Node | null;
109 readonly innerHTML: string;
110 readonly textContent: string;
111 readonly childNodes: Node[];
112 readonly delegatesFocus: boolean;
113 addEventListener(
114 type: string,
115 listener: EventListenerOrEventListenerObject,
116 options?: boolean | AddEventListenerOptions
117 ): void;
118 removeEventListener(
119 type: string,
120 listener: EventListenerOrEventListenerObject,
121 options?: boolean | EventListenerOptions
122 ): void;
123 hasChildNodes(): boolean;
124 compareDocumentPosition(otherNode: Node): number;
125 contains(otherNode: Node): boolean;
126 elementFromPoint(x: number, y: number): Element | null;
127 }
128
129 /**
130 * Base class for the Lightning Web Component JavaScript class
131 */
132 export class LightningElement extends HTMLElementTheGoodPart {
133 /**
134 * Called when the element is inserted in a document
135 */
136 connectedCallback(): void;
137 /**
138 * Called when the element is removed from a document
139 */
140 disconnectedCallback(): void;
141 /**
142 * Called after every render of the component
143 */
144 renderedCallback(): void;
145 /**
146 * Called when a descendant component throws an error in one of its lifecycle hooks
147 */
148 errorCallback(error: Error, stack: string): void;
149
150 readonly template: ShadowRootTheGoodPart;
151 readonly shadowRoot: null;
152 }
153
154 /**
155 * Decorator to mark public reactive properties
156 */
157 export const api: PropertyDecorator;
158
159 /**
160 * Decorator to mark private reactive properties
161 */
162 export const track: PropertyDecorator;
163
164 /**
165 * Decorator factory to wire a property or method to a wire adapter data source
166 * @param getType imperative accessor for the data source
167 * @param config configuration object for the accessor
168 */
169 export function wire(getType: (config?: any) => any, config?: any): PropertyDecorator;
170}