UNPKG

16 kBTypeScriptView Raw
1// Type definitions for Office.js 1.0
2// Project: https://github.com/OfficeDev/office-js
3// Definitions by: OfficeDev <https://github.com/OfficeDev>,
4// Ricky Kirkham <https://github.com/Rick-Kirkham>,
5// Alex Jerabek <https://github.com/AlexJerabek>,
6// Elizabeth Samuel <https://github.com/ElizabethSamuel-MSFT>,
7// Alison McKay <https://github.com/alison-mk>,
8// Sam Ramon <https://github.com/samantharamon>
9// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
10// TypeScript Version: 2.4
11
12/*
13office-js
14Copyright (c) Microsoft Corporation
15*/
16
17
18////////////////////////////////////////////////////////////////
19//////////////////// Begin Office namespace ////////////////////
20////////////////////////////////////////////////////////////////
21
22declare namespace Office {
23 /** A Promise object. Promises can be chained via ".then", and errors can be caught via ".catch".
24 * When a browser-provided native Promise implementation is available, Office.Promise will switch to use the native Promise instead.
25 */
26 var Promise: IPromiseConstructor;
27
28 // **Note**: this is a copy of the PromiseConstructor object from
29 // https://github.com/Microsoft/TypeScript/blob/master/lib/lib.es2015.promise.d.ts
30 // It is necessary so that even with targeting "ES5" and not specifying any libs,
31 // developers will still get IntelliSense for "Office.Promise" just as they would with a regular Promise.
32 // (because even though Promise is part of standard lib.d.ts, PromiseConstructor is not)
33 interface IPromiseConstructor {
34 /**
35 * A reference to the prototype.
36 */
37 readonly prototype: Promise<any>;
38
39 /**
40 * Creates a new Promise.
41 * @param executor A callback used to initialize the promise. This callback is passed two arguments:
42 * a resolve callback used resolve the promise with a value or the result of another promise,
43 * and a reject callback used to reject the promise with a provided reason or error.
44 */
45 new <T>(executor: (resolve: (value?: T | PromiseLike<T>) => void, reject: (reason?: any) => void) => void): Promise<T>;
46
47 /**
48 * Creates a Promise that is resolved with an array of results when all of the provided Promises
49 * resolve, or rejected when any Promise is rejected.
50 * @param values An array of Promises.
51 * @returns A new Promise.
52 */
53 all<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10]>;
54
55 /**
56 * Creates a Promise that is resolved with an array of results when all of the provided Promises
57 * resolve, or rejected when any Promise is rejected.
58 * @param values An array of Promises.
59 * @returns A new Promise.
60 */
61 all<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8, T9]>;
62
63 /**
64 * Creates a Promise that is resolved with an array of results when all of the provided Promises
65 * resolve, or rejected when any Promise is rejected.
66 * @param values An array of Promises.
67 * @returns A new Promise.
68 */
69 all<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<[T1, T2, T3, T4, T5, T6, T7, T8]>;
70
71 /**
72 * Creates a Promise that is resolved with an array of results when all of the provided Promises
73 * resolve, or rejected when any Promise is rejected.
74 * @param values An array of Promises.
75 * @returns A new Promise.
76 */
77 all<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<[T1, T2, T3, T4, T5, T6, T7]>;
78
79 /**
80 * Creates a Promise that is resolved with an array of results when all of the provided Promises
81 * resolve, or rejected when any Promise is rejected.
82 * @param values An array of Promises.
83 * @returns A new Promise.
84 */
85 all<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<[T1, T2, T3, T4, T5, T6]>;
86
87 /**
88 * Creates a Promise that is resolved with an array of results when all of the provided Promises
89 * resolve, or rejected when any Promise is rejected.
90 * @param values An array of Promises.
91 * @returns A new Promise.
92 */
93 all<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<[T1, T2, T3, T4, T5]>;
94
95 /**
96 * Creates a Promise that is resolved with an array of results when all of the provided Promises
97 * resolve, or rejected when any Promise is rejected.
98 * @param values An array of Promises.
99 * @returns A new Promise.
100 */
101 all<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<[T1, T2, T3, T4]>;
102
103 /**
104 * Creates a Promise that is resolved with an array of results when all of the provided Promises
105 * resolve, or rejected when any Promise is rejected.
106 * @param values An array of Promises.
107 * @returns A new Promise.
108 */
109 all<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<[T1, T2, T3]>;
110
111 /**
112 * Creates a Promise that is resolved with an array of results when all of the provided Promises
113 * resolve, or rejected when any Promise is rejected.
114 * @param values An array of Promises.
115 * @returns A new Promise.
116 */
117 all<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<[T1, T2]>;
118
119 /**
120 * Creates a Promise that is resolved with an array of results when all of the provided Promises
121 * resolve, or rejected when any Promise is rejected.
122 * @param values An array of Promises.
123 * @returns A new Promise.
124 */
125 all<T>(values: (T | PromiseLike<T>)[]): Promise<T[]>;
126
127 /**
128 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
129 * or rejected.
130 * @param values An array of Promises.
131 * @returns A new Promise.
132 */
133 race<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>, T10 | PromiseLike<T10>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9 | T10>;
134
135 /**
136 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
137 * or rejected.
138 * @param values An array of Promises.
139 * @returns A new Promise.
140 */
141 race<T1, T2, T3, T4, T5, T6, T7, T8, T9>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>, T9 | PromiseLike<T9>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>;
142
143 /**
144 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
145 * or rejected.
146 * @param values An array of Promises.
147 * @returns A new Promise.
148 */
149 race<T1, T2, T3, T4, T5, T6, T7, T8>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>, T8 | PromiseLike<T8>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7 | T8>;
150
151 /**
152 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
153 * or rejected.
154 * @param values An array of Promises.
155 * @returns A new Promise.
156 */
157 race<T1, T2, T3, T4, T5, T6, T7>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>, T7 | PromiseLike<T7>]): Promise<T1 | T2 | T3 | T4 | T5 | T6 | T7>;
158
159 /**
160 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
161 * or rejected.
162 * @param values An array of Promises.
163 * @returns A new Promise.
164 */
165 race<T1, T2, T3, T4, T5, T6>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>, T6 | PromiseLike<T6>]): Promise<T1 | T2 | T3 | T4 | T5 | T6>;
166
167 /**
168 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
169 * or rejected.
170 * @param values An array of Promises.
171 * @returns A new Promise.
172 */
173 race<T1, T2, T3, T4, T5>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>, T5 | PromiseLike<T5>]): Promise<T1 | T2 | T3 | T4 | T5>;
174
175 /**
176 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
177 * or rejected.
178 * @param values An array of Promises.
179 * @returns A new Promise.
180 */
181 race<T1, T2, T3, T4>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>, T4 | PromiseLike<T4>]): Promise<T1 | T2 | T3 | T4>;
182
183 /**
184 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
185 * or rejected.
186 * @param values An array of Promises.
187 * @returns A new Promise.
188 */
189 race<T1, T2, T3>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>, T3 | PromiseLike<T3>]): Promise<T1 | T2 | T3>;
190
191 /**
192 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
193 * or rejected.
194 * @param values An array of Promises.
195 * @returns A new Promise.
196 */
197 race<T1, T2>(values: [T1 | PromiseLike<T1>, T2 | PromiseLike<T2>]): Promise<T1 | T2>;
198
199 /**
200 * Creates a Promise that is resolved or rejected when any of the provided Promises are resolved
201 * or rejected.
202 * @param values An array of Promises.
203 * @returns A new Promise.
204 */
205 race<T>(values: (T | PromiseLike<T>)[]): Promise<T>;
206
207 /**
208 * Creates a new rejected promise for the provided reason.
209 * @param reason The reason the promise was rejected.
210 * @returns A new rejected Promise.
211 */
212 reject(reason: any): Promise<never>;
213
214 /**
215 * Creates a new rejected promise for the provided reason.
216 * @param reason The reason the promise was rejected.
217 * @returns A new rejected Promise.
218 */
219 reject<T>(reason: any): Promise<T>;
220
221 /**
222 * Creates a new resolved promise for the provided value.
223 * @param value A promise.
224 * @returns A promise whose internal state matches the provided promise.
225 */
226 resolve<T>(value: T | PromiseLike<T>): Promise<T>;
227
228 /**
229 * Creates a new resolved promise.
230 * @returns A resolved promise.
231 */
232 resolve(): Promise<void>;
233 }
234
235 /**
236 * Gets the Context object that represents the runtime environment of the add-in and provides access to the top-level objects of the API.
237 *
238 * @remarks
239 *
240 * **Support details**
241 *
242 * A capital Y in the following matrix indicates that this property is supported in the corresponding Office host application.
243 * An empty cell indicates that the Office host application doesn't support this enumeration.
244 *
245 * For more information about Office host application and server requirements, see
246 * {@link https://docs.microsoft.com/office/dev/add-ins/concepts/requirements-for-running-office-add-ins | Requirements for running Office Add-ins}.
247 *
248 * *Supported hosts, by platform*
249 * <table>
250 * <tr><th> </th><th> Office on Windows </th><th> Office in web browser </th><th> Office on iPad </th><th> Outlook on mobile devices </th><th> Office on Mac </th></tr>
251 * <tr><td><strong> Excel </strong></td><td> Y </td><td> Y </td><td> Y </td><td> </td><td> Y </td></tr>
252 * <tr><td><strong> Outlook </strong></td><td> Y </td><td> Y </td><td> </td><td> Y </td><td> Y </td></tr>
253 * <tr><td><strong> PowerPoint </strong></td><td> Y </td><td> Y </td><td> Y </td><td> </td><td> Y </td></tr>
254 * <tr><td><strong> Project </strong></td><td> Y </td><td> </td><td> </td><td> </td><td> Y </td></tr>
255 * <tr><td><strong> Word </strong></td><td> Y </td><td> Y </td><td> Y </td><td> </td><td> Y </td></tr>
256 * </table>
257 */
258 var context: Context;
259 /**
260 * Occurs when the runtime environment is loaded and the add-in is ready to start interacting with the application and hosted document.
261 *
262 * The reason parameter of the initialize event listener function returns an `InitializationReason` enumeration value that specifies how
263 * initialization occurred. A task pane or content add-in can be initialized in two ways:
264 *
265 * - The user just inserted it from Recently Used Add-ins section of the Add-in drop-down list on the Insert tab of the ribbon in the Office
266 * host application, or from Insert add-in dialog box.
267 *
268 * - The user opened a document that already contains the add-in.
269 *
270 * *Note*: The reason parameter of the initialize event listener function only returns an `InitializationReason` enumeration value for task pane
271 * and content add-ins. It does not return a value for Outlook add-ins.
272 *
273 * @remarks
274 *
275 * **Support details**
276 *
277 * A capital Y in the following matrix indicates that this method is supported in the corresponding Office host application.
278 * An empty cell indicates that the Office host application doesn't support this method.
279 *
280 * For more information about Office host application and server requirements, see
281 * {@link https://docs.microsoft.com/office/dev/add-ins/concepts/requirements-for-running-office-add-ins | Requirements for running Office Add-ins}.
282 *
283
\No newline at end of file