From e4928b84bcb018dbc872107c6aa8d6c83fc5b8d4 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 14:28:51 -0700 Subject: [PATCH 01/16] adding custom functions --- .../custom-functions-runtime-tests.ts | 32 ++++++++ types/custom-functions-runtime/index.d.ts | 30 +++++++ types/custom-functions-runtime/tsconfig.json | 23 ++++++ types/custom-functions-runtime/tslint.json | 79 +++++++++++++++++++ 4 files changed, 164 insertions(+) create mode 100644 types/custom-functions-runtime/custom-functions-runtime-tests.ts create mode 100644 types/custom-functions-runtime/index.d.ts create mode 100644 types/custom-functions-runtime/tsconfig.json create mode 100644 types/custom-functions-runtime/tslint.json diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts new file mode 100644 index 0000000000..d23e2e60e6 --- /dev/null +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -0,0 +1,32 @@ +function ADD10(n: number) { + return n + 10; +} + +declare const CustomFunctionMappings: { + "addTen": ADD10(); +}; + +async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + handler.setResult(dollars) +} + +async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { + var shouldStop = false; + handler.onCanceled = () => shouldStop = true; + await pause(1000); + + if (shouldStop) { + return null; + } + + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + return dollars; +} + +async function getStockValuesNowWithNoCancelling(ticker: string) { + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + return dollars; +} + +declare function pause(ms: number): Promise diff --git a/types/custom-functions-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts new file mode 100644 index 0000000000..3bab36de3c --- /dev/null +++ b/types/custom-functions-runtime/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for Custom Functions +// Project: http://dev.office.com +// Definitions by: OfficeDev , Michael Zlatkovsky , Michelle Scharlock +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/* +office-js +Copyright (c) Microsoft Corporation +*/ + +declare const CustomFunctionMappings: { [key: string]: Function }; + +declare namespace CustomFunctions { + interface StreamingHandler extends CancelableHandler { + /* + * Sets the returned result for a streaming custom function. + * @beta + */ + setResult: (value: T) => void; + } + + interface CancelableHandler { + /* + * Handles what should occur when a custom function is canceled. + * @beta + */ + onCanceled: () => void; + } +} diff --git a/types/custom-functions-runtime/tsconfig.json b/types/custom-functions-runtime/tsconfig.json new file mode 100644 index 0000000000..b3da8763ec --- /dev/null +++ b/types/custom-functions-runtime/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "target": "es6" + }, + "files": [ + "index.d.ts", + "office-runtime-tests.ts" + ] +} diff --git a/types/custom-functions-runtime/tslint.json b/types/custom-functions-runtime/tslint.json new file mode 100644 index 0000000000..5c50b51e66 --- /dev/null +++ b/types/custom-functions-runtime/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} \ No newline at end of file From 2bc6766ea52b9f3fb7fdceb5a3755436f5bd1a52 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 14:30:08 -0700 Subject: [PATCH 02/16] removed office runtime --- types/office-runtime/index.d.ts | 155 ------------------- types/office-runtime/office-runtime-tests.ts | 77 --------- types/office-runtime/tsconfig.json | 23 --- types/office-runtime/tslint.json | 79 ---------- 4 files changed, 334 deletions(-) delete mode 100644 types/office-runtime/index.d.ts delete mode 100644 types/office-runtime/office-runtime-tests.ts delete mode 100644 types/office-runtime/tsconfig.json delete mode 100644 types/office-runtime/tslint.json diff --git a/types/office-runtime/index.d.ts b/types/office-runtime/index.d.ts deleted file mode 100644 index 4e45c8dc82..0000000000 --- a/types/office-runtime/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -// Type definitions for office-runtime -// Project: http://dev.office.com/ -// Definitions by: Michael Zlatskovsky , Michelle Scharlock -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Typescript Version: 2.4 - -/* -office-runtime -Copyright (c) Microsoft Corporation -*/ - -declare namespace OfficeRuntime { - function displayWebDialog(url: string, options: DisplayWebDialogOptions): Promise; - const AsyncStorage: AsyncStorage; - - // tslint:disable-next-line:interface-name - /** - * Asynchronous, global, and persistent key-value storage for Excel Custom Functions only. - * @beta - * - * @remarks - * Each add-in instance has its own storage partition, unique to a user and their device. - * - * The default amount of total storage allowed per add-in is 5MB. - * - * Each method listed below returns a Promise object. - * - */ - interface AsyncStorage { - /** - * @beta - * Retrieves an object based on a key and invokes a callback when finished. Returns a Promise. - * - */ - getItem(key: string, callback?: (error?: Error, result?: string) => void): Promise; - /** - * @beta - * Assigns the value for a key-value pair and invokes a callback when finished. Returns a Promise. - * - */ - setItem(key: string, value: string, callback?: (error?: Error) => void): Promise; - /** - * @beta - * Removes an item for specified key and invokes a callback when finished. Returns a Promise. - * - * - */ - removeItem(key: string, callback?: (error?: Error) => void): Promise; - /** - * @beta - * Erases all AsyncStorage. Returns a Promise. - * - */ - clear(callback?: (error?: Error) => void): Promise; - /** - * @beta - * Returns a Promise with all keys for your custom function. - * - */ - getAllKeys(callback?: (error?: Error, keys?: string[]) => void): Promise; - /** - * @beta - * Stores multiple key-value pairs in one batch. Returns a Promise. When a key doesn't exist, returns null. - * - */ - multiSet(keyValuePairs: string[][], callback?: (errors?: Error[]) => void): Promise; - /** - * @beta - * Deletes a batch of keys, specified in the `keys` array. - * - */ - multiRemove(keys: string[], callback?: (errors?: Error[]) => void): Promise;/** - /** - * @beta - * Fetches a batch of keys, specified in the `keys` array. When a key doesn't exist, returns null. - * - */ - multiGet(keys: string[], callback?: (errors?: Error[], result?: string[][]) => void): Promise; - } - - /** - * @beta - * Object representing the dialog box for Excel Custom Functions only. - * - */ - interface Dialog { - /** - * @beta - * Method that closes a dialog box. - */ - close(): Promise; - } - - /** - * - * Provides options for how a dialog is displayed for Excel Custom Functions only. - * - */ - interface DisplayWebDialogOptions { - /** - * @beta - * Determines whether the dialog box displays as a popup (false) or within an IFrame (true). This setting is only applicable to custom functions running on Excel Online. - * - * [Api set: Dialog 1.2] - */ - displayInIFrame?: boolean; - /** - * @beta - * Defines the height of the dialog box as a percentage of the current display. - * - * [Api set: Dialog 1.2] - */ - height?: string; - - /** - * @beta - * Defines the width of the dialog box as a percentage of the current display. - * - * [Api set: Dialog 1.2] - */ - width?: string; - - /** - * @beta - * True if title is hidden from the dialog box. - * - * [Api set: Dialog 1.2] - */ - hideTitle?: boolean; - - /** - * @beta - * Callback that is run when the dialog box sends a message to its parent. - * - * - */ - onMessage?: (message: string, dialog?: Dialog) => void; - - /** - * @beta - * Callback that is run when the dialog box is closed. - * - * - */ - onClose?: () => void; - - /** - * @beta - * Callback that is run when the dialog box sends an error. - * - * - */ - onRuntimeError?: (error: Error, dialog?: Dialog) => void; - } - } diff --git a/types/office-runtime/office-runtime-tests.ts b/types/office-runtime/office-runtime-tests.ts deleted file mode 100644 index a8d8f09675..0000000000 --- a/types/office-runtime/office-runtime-tests.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* -office-runtime -Copyright (c) Microsoft Corporation -*/ - -OfficeRuntime.AsyncStorage.getItem("foo", () => { - //do a thing -}) -OfficeRuntime.AsyncStorage.getItem("foo").then(value => console.log(value)) - -OfficeRuntime.AsyncStorage.setItem("foo", "bar"); -OfficeRuntime.AsyncStorage.setItem("foo", "bar").then(error => console.log(error)) - -OfficeRuntime.AsyncStorage.removeItem("foo"); -OfficeRuntime.AsyncStorage.removeItem("foo", () => { - //do a thing -}) - -OfficeRuntime.AsyncStorage.clear(); -OfficeRuntime.AsyncStorage.clear(() => { - //do a thing -}) - -OfficeRuntime.AsyncStorage.getAllKeys().then(keys => { - keys.forEach(item => console.log(item)); -}) -OfficeRuntime.AsyncStorage.getAllKeys((error, keys) => { - if (error) { - console.error(error); - } else { - keys.forEach(item => console.log(item)); - } -}) - -OfficeRuntime.AsyncStorage.multiSet( - [["username", "foo"], ["yearOfBirth", "2001"]], - errors => { - errors.filter(error => error != null).forEach(error => console.log(error)); - } -) - -OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]); -OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]).then(value => console.log(value)) - -OfficeRuntime.AsyncStorage.multiGet(["username", "yearOfBirth"]).then( - values => { - console.log(values[0][1]) - console.log(values[1][1]) - } -) - - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - height: '50', - width: '50%', - displayInIFrame: false, - hideTitle: true, -     onMessage: (message, dialog) => { -         console.log(message); -             dialog.close(); -             } - } -) - - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - onClose: () => { - console.log("closed"); - } -}) - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - onRuntimeError: (error, dialog) => { - console.log(error); - dialog.close(); - } -}) \ No newline at end of file diff --git a/types/office-runtime/tsconfig.json b/types/office-runtime/tsconfig.json deleted file mode 100644 index 0609e72ad0..0000000000 --- a/types/office-runtime/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": ["../"], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "target": "es6" - }, - "files": [ - "index.d.ts", - "office-runtime-tests.ts" - ] -} \ No newline at end of file diff --git a/types/office-runtime/tslint.json b/types/office-runtime/tslint.json deleted file mode 100644 index 5c50b51e66..0000000000 --- a/types/office-runtime/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} \ No newline at end of file From 1def2646d99d0776bec722e3b390e70eadcb59cc Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 14:32:50 -0700 Subject: [PATCH 03/16] renaming file --- .../custom-functions-runtime-tests.ts | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 types/custom-functions-runtime/custom-functions-runtime-tests.ts diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts deleted file mode 100644 index d23e2e60e6..0000000000 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ /dev/null @@ -1,32 +0,0 @@ -function ADD10(n: number) { - return n + 10; -} - -declare const CustomFunctionMappings: { - "addTen": ADD10(); -}; - -async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - handler.setResult(dollars) -} - -async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { - var shouldStop = false; - handler.onCanceled = () => shouldStop = true; - await pause(1000); - - if (shouldStop) { - return null; - } - - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - return dollars; -} - -async function getStockValuesNowWithNoCancelling(ticker: string) { - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - return dollars; -} - -declare function pause(ms: number): Promise From 2d4a4a2b63b7af3b861b2903d4a20cee686817ab Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 14:33:57 -0700 Subject: [PATCH 04/16] AHA finally fixing error --- types/custom-functions-runtime/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/custom-functions-runtime/tsconfig.json b/types/custom-functions-runtime/tsconfig.json index b3da8763ec..3c8cbbaf27 100644 --- a/types/custom-functions-runtime/tsconfig.json +++ b/types/custom-functions-runtime/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "office-runtime-tests.ts" + "custom-functions-runtime-tests.ts" ] } From 45c99bd450b06254c9bdcfc1f0b2a20c66f3842d Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 14:34:54 -0700 Subject: [PATCH 05/16] making it ts --- .../custom-functions-runtime-tests.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 types/custom-functions-runtime/custom-functions-runtime-tests.ts diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts new file mode 100644 index 0000000000..d23e2e60e6 --- /dev/null +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -0,0 +1,32 @@ +function ADD10(n: number) { + return n + 10; +} + +declare const CustomFunctionMappings: { + "addTen": ADD10(); +}; + +async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + handler.setResult(dollars) +} + +async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { + var shouldStop = false; + handler.onCanceled = () => shouldStop = true; + await pause(1000); + + if (shouldStop) { + return null; + } + + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + return dollars; +} + +async function getStockValuesNowWithNoCancelling(ticker: string) { + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + return dollars; +} + +declare function pause(ms: number): Promise From 1de741110df077610c545f26db3debe99319e740 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 15:08:55 -0700 Subject: [PATCH 06/16] Ok CFMapp now doesn't have errors but tests still not working --- .../custom-functions-runtime/custom-functions-runtime-tests.ts | 3 ++- types/custom-functions-runtime/index.d.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts index d23e2e60e6..0cdec4960a 100644 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -2,7 +2,7 @@ function ADD10(n: number) { return n + 10; } -declare const CustomFunctionMappings: { +const CustomFunctionMappings: { "addTen": ADD10(); }; @@ -30,3 +30,4 @@ async function getStockValuesNowWithNoCancelling(ticker: string) { } declare function pause(ms: number): Promise +n \ No newline at end of file diff --git a/types/custom-functions-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts index 3bab36de3c..0173a4d0ed 100644 --- a/types/custom-functions-runtime/index.d.ts +++ b/types/custom-functions-runtime/index.d.ts @@ -9,7 +9,7 @@ office-js Copyright (c) Microsoft Corporation */ -declare const CustomFunctionMappings: { [key: string]: Function }; +declare let CustomFunctionMappings: { [key: string]: Function }; declare namespace CustomFunctions { interface StreamingHandler extends CancelableHandler { From 51363d2e62481891fa71ed5362ca8d17f11bc50d Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 15:13:54 -0700 Subject: [PATCH 07/16] update to tests so it now runs --- .../custom-functions-runtime-tests.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts index 0cdec4960a..4882c6bcd2 100644 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -2,8 +2,8 @@ function ADD10(n: number) { return n + 10; } -const CustomFunctionMappings: { - "addTen": ADD10(); +CustomFunctionMappings = { + "addTen": ADD10 }; async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { @@ -30,4 +30,3 @@ async function getStockValuesNowWithNoCancelling(ticker: string) { } declare function pause(ms: number): Promise -n \ No newline at end of file From 130faec254a0be3139c310fccf9b12d94fc932f9 Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Mon, 17 Sep 2018 09:52:24 -0700 Subject: [PATCH 08/16] Getting rid of excessive lint things --- types/custom-functions-runtime/tslint.json | 80 +--------------------- 1 file changed, 2 insertions(+), 78 deletions(-) diff --git a/types/custom-functions-runtime/tslint.json b/types/custom-functions-runtime/tslint.json index 5c50b51e66..f93cf8562a 100644 --- a/types/custom-functions-runtime/tslint.json +++ b/types/custom-functions-runtime/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} \ No newline at end of file + "extends": "dtslint/dt.json" +} From acce8fa96d87ba62253c15ae4374473482e8d2f1 Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Mon, 17 Sep 2018 17:13:42 -0700 Subject: [PATCH 09/16] Update to tslint.json --- types/custom-functions-runtime/tslint.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/custom-functions-runtime/tslint.json b/types/custom-functions-runtime/tslint.json index f93cf8562a..916693cb02 100644 --- a/types/custom-functions-runtime/tslint.json +++ b/types/custom-functions-runtime/tslint.json @@ -1,3 +1,6 @@ { "extends": "dtslint/dt.json" + "rules": { + "semicolon": false, + } } From 1bf25df514d5a8aede2123f8dd23e34b6291301c Mon Sep 17 00:00:00 2001 From: mscharlock Date: Mon, 17 Sep 2018 17:24:36 -0700 Subject: [PATCH 10/16] update to json so it's not broken --- .../custom-functions-runtime-tests.ts | 6 +++--- types/custom-functions-runtime/tslint.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts index 4882c6bcd2..0186416e95 100644 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -2,8 +2,8 @@ function ADD10(n: number) { return n + 10; } -CustomFunctionMappings = { - "addTen": ADD10 +CustomFunctionMappings = { + addTen: ADD10 }; async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { @@ -12,7 +12,7 @@ async function getStockValues(ticker: string, handler: CustomFunctions.Streaming } async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { - var shouldStop = false; + let shouldStop = false; handler.onCanceled = () => shouldStop = true; await pause(1000); diff --git a/types/custom-functions-runtime/tslint.json b/types/custom-functions-runtime/tslint.json index 916693cb02..837163b606 100644 --- a/types/custom-functions-runtime/tslint.json +++ b/types/custom-functions-runtime/tslint.json @@ -1,6 +1,6 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", "rules": { - "semicolon": false, + "semicolon": false } } From abfae224423083b98141e8e2623cc8bc9b0a6732 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Mon, 17 Sep 2018 17:37:25 -0700 Subject: [PATCH 11/16] Fix failures --- types/custom-functions-runtime/index.d.ts | 8 ++++---- types/custom-functions-runtime/tslint.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/types/custom-functions-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts index 0173a4d0ed..e233a869fd 100644 --- a/types/custom-functions-runtime/index.d.ts +++ b/types/custom-functions-runtime/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Custom Functions +// Type definitions for Custom Functions 1.4 // Project: http://dev.office.com // Definitions by: OfficeDev , Michael Zlatkovsky , Michelle Scharlock // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -14,7 +14,7 @@ declare let CustomFunctionMappings: { [key: string]: Function }; declare namespace CustomFunctions { interface StreamingHandler extends CancelableHandler { /* - * Sets the returned result for a streaming custom function. + * Sets the returned result for a streaming custom function. * @beta */ setResult: (value: T) => void; @@ -22,8 +22,8 @@ declare namespace CustomFunctions { interface CancelableHandler { /* - * Handles what should occur when a custom function is canceled. - * @beta + * Handles what should occur when a custom function is canceled. + * @beta */ onCanceled: () => void; } diff --git a/types/custom-functions-runtime/tslint.json b/types/custom-functions-runtime/tslint.json index 837163b606..a62d0d4e68 100644 --- a/types/custom-functions-runtime/tslint.json +++ b/types/custom-functions-runtime/tslint.json @@ -1,6 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "semicolon": false + "ban-types": false } } From 23a045349226125eab25097aa6ec389d429c5008 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Mon, 17 Sep 2018 17:42:40 -0700 Subject: [PATCH 12/16] Fix lint issue --- .../custom-functions-runtime-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts index 0186416e95..9d01cc64e6 100644 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -8,7 +8,7 @@ CustomFunctionMappings = { async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - handler.setResult(dollars) + handler.setResult(dollars); } async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { @@ -29,4 +29,4 @@ async function getStockValuesNowWithNoCancelling(ticker: string) { return dollars; } -declare function pause(ms: number): Promise +declare function pause(ms: number): Promise; From 5ced13eaee0e3c1e60edef0bd5838f28eeebc6ad Mon Sep 17 00:00:00 2001 From: mscharlock Date: Tue, 18 Sep 2018 10:00:30 -0700 Subject: [PATCH 13/16] adding a note on the test fcn --- types/custom-functions-runtime/custom-functions-runtime-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts index 9d01cc64e6..335e5a1f95 100644 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -1,3 +1,4 @@ +/* Note that this is a sample function for the purpose of running the below CustomFunctionsMappings test */ function ADD10(n: number) { return n + 10; } From 502af779fb6a9c77f1d30e6ad5af34e01283a0dd Mon Sep 17 00:00:00 2001 From: mscharlock Date: Wed, 19 Sep 2018 21:34:31 -0700 Subject: [PATCH 14/16] adding comment --- types/custom-functions-runtime/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/custom-functions-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts index e233a869fd..3b44fb9d21 100644 --- a/types/custom-functions-runtime/index.d.ts +++ b/types/custom-functions-runtime/index.d.ts @@ -9,6 +9,9 @@ office-js Copyright (c) Microsoft Corporation */ +/* +* Enables you to map your own name that uses lowercase letters to a function. +*/ declare let CustomFunctionMappings: { [key: string]: Function }; declare namespace CustomFunctions { From 08d723da665a627a31cbe6a38235a3f34e535896 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Thu, 20 Sep 2018 11:49:42 -0700 Subject: [PATCH 15/16] adding comments & end/begin --- types/custom-functions-runtime/index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/types/custom-functions-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts index 3b44fb9d21..94c58c6b7b 100644 --- a/types/custom-functions-runtime/index.d.ts +++ b/types/custom-functions-runtime/index.d.ts @@ -9,6 +9,11 @@ office-js Copyright (c) Microsoft Corporation */ + +//////////////////////////////////////////////////////////////// +//////////////////// Begin custom-functions-runtime //////////// +//////////////////////////////////////////////////////////////// + /* * Enables you to map your own name that uses lowercase letters to a function. */ @@ -31,3 +36,8 @@ declare namespace CustomFunctions { onCanceled: () => void; } } + + +//////////////////////////////////////////////////////////////// +//////////////////// BEnd custom-functions-runtime //////////// +//////////////////////////////////////////////////////////////// \ No newline at end of file From 5542f92ec15f5642166896e17260194e849c454f Mon Sep 17 00:00:00 2001 From: mscharlock Date: Thu, 20 Sep 2018 11:55:15 -0700 Subject: [PATCH 16/16] remove office things --- types/office-runtime/index.d.ts | 117 ------------------- types/office-runtime/office-runtime-tests.ts | 61 ---------- types/office-runtime/tslint.json | 3 - 3 files changed, 181 deletions(-) delete mode 100644 types/office-runtime/index.d.ts delete mode 100644 types/office-runtime/office-runtime-tests.ts delete mode 100644 types/office-runtime/tslint.json diff --git a/types/office-runtime/index.d.ts b/types/office-runtime/index.d.ts deleted file mode 100644 index 3f57014bc9..0000000000 --- a/types/office-runtime/index.d.ts +++ /dev/null @@ -1,117 +0,0 @@ -// Type definitions for office-runtime 1.0 -// Project: http://dev.office.com/ -// Definitions by: Michael Zlatskovsky , Michelle Scharlock -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Typescript Version: 2.4 - -/* -office-runtime -Copyright (c) Microsoft Corporation -*/ - -declare namespace OfficeRuntime { - function displayWebDialog(url: string, options: DisplayWebDialogOptions): Promise; - const AsyncStorage: AsyncStorage; - - // tslint:disable-next-line:interface-name - /* - * Asynchronous, global, and persistent key-value storage that can be used by Excel Custom Functions. - * @beta - * - * @remarks - * Each add-in instance has its own storage partition, unique to a user and their device. - * - * The default amount of total storage allowed per add-in is 5MB. - * - * Each method listed below returns a Promise object. - * - */ - interface AsyncStorage { - /* - * @beta - * Retrieves an object based on a key and invokes a callback when finished. Returns a Promise. - */ - getItem(key: string, callback?: (error?: Error, result?: string) => void): Promise; - /* - * @beta - * Assigns the value for a key-value pair and invokes a callback when finished. Returns a Promise. - */ - setItem(key: string, value: string, callback?: (error?: Error) => void): Promise; - /* - * @beta - * Removes an item for specified key and invokes a callback when finished. Returns a Promise. - */ - removeItem(key: string, callback?: (error?: Error) => void): Promise; - /* - * @beta - * Erases all AsyncStorage. Returns a Promise. - */ - clear(callback?: (error?: Error) => void): Promise; - /* - * @beta - * Returns a Promise with all keys. - */ - getAllKeys(callback?: (error?: Error, keys?: string[]) => void): Promise; - /* - * @beta - * Stores multiple key-value pairs in one batch. Returns a Promise. When a key doesn't exist, returns null. - */ - multiSet(keyValuePairs: string[][], callback?: (errors?: Error[]) => void): Promise; - /* - * @beta - * Deletes a batch of keys, specified in the `keys` array. - */ - multiRemove(keys: string[], callback?: (errors?: Error[]) => void): Promise; - /* - * @beta - * Fetches a batch of keys, specified in the `keys` array. When a key doesn't exist, returns null. - */ - multiGet(keys: string[], callback?: (errors?: Error[], result?: string[][]) => void): Promise; - } - /* - * @beta - * Object representing the dialog box. - */ - interface Dialog { - /* - * @beta - * Method that closes a dialog box. - */ - close(): Promise; - } - /* - * Provides options for how a dialog is displayed. - */ - interface DisplayWebDialogOptions { - /* - * @beta - * Determines whether the dialog box displays as a popup (false) or within an IFrame (true). This setting is only applicable to custom functions running on Excel Online. - */ - displayInIFrame?: boolean; - /* - * @beta - * Defines the height of the dialog box as a percentage of the current display. - */ - height?: string; - /* - * @beta - * Defines the width of the dialog box as a percentage of the current display. - */ - width?: string; - /* - * @beta - * True if title is hidden from the dialog box. - */ - hideTitle?: boolean; - /* - * @beta - * Callback that is run when the dialog box is closed. - */ - onClose?: () => void; - /* - * @beta - * Callback that is run when the dialog box sends an error. - */ - onMessage?(message: string, dialog?: Dialog): void; - } - } diff --git a/types/office-runtime/office-runtime-tests.ts b/types/office-runtime/office-runtime-tests.ts deleted file mode 100644 index 889665b3df..0000000000 --- a/types/office-runtime/office-runtime-tests.ts +++ /dev/null @@ -1,61 +0,0 @@ -/* -office-runtime -Copyright (c) Microsoft Corporation -*/ - -OfficeRuntime.AsyncStorage.getItem("foo", () => { - // perform an action -}); -OfficeRuntime.AsyncStorage.getItem("foo").then(value => console.log(value)); - -OfficeRuntime.AsyncStorage.setItem("foo", "bar"); -OfficeRuntime.AsyncStorage.setItem("foo", "bar").then(error => console.log(error)); - -OfficeRuntime.AsyncStorage.removeItem("foo"); -OfficeRuntime.AsyncStorage.removeItem("foo", () => { - // perform an action -}); - -OfficeRuntime.AsyncStorage.clear(); -OfficeRuntime.AsyncStorage.clear(() => { - // perform an action -}); - -OfficeRuntime.AsyncStorage.getAllKeys().then(keys => { - keys.forEach(item => console.log(item)); -}); - -OfficeRuntime.AsyncStorage.getAllKeys((error, keys) => { - if (error) { - console.error(error); - } else { - keys.forEach(item => console.log(item)); - } -}); - -OfficeRuntime.AsyncStorage.multiSet( - [["username", "foo"], ["yearOfBirth", "2001"]], - errors => { - errors.filter(error => error != null).forEach(error => console.log(error)); - } -); - -OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]); -OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]).then(value => console.log(value)); - -OfficeRuntime.AsyncStorage.multiGet(["username", "yearOfBirth"]).then( - values => { - console.log(values[0][1]); - console.log(values[1][1]); - } -); - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - displayInIFrame: false -}); - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - onClose: () => { - console.log("closed"); - } -}); diff --git a/types/office-runtime/tslint.json b/types/office-runtime/tslint.json deleted file mode 100644 index f93cf8562a..0000000000 --- a/types/office-runtime/tslint.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "extends": "dtslint/dt.json" -}