diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index 7aec4de9..00373a68 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -18,4 +18,5 @@ interface Window { Olm: { init: () => Promise; }; + mxSendRageshake: (text: string, withLogs?: boolean) => void; } diff --git a/src/vector/getconfig.js b/src/vector/getconfig.ts similarity index 94% rename from src/vector/getconfig.js rename to src/vector/getconfig.ts index c0f81f6c..36c36cce 100644 --- a/src/vector/getconfig.js +++ b/src/vector/getconfig.ts @@ -18,8 +18,7 @@ import request from 'browser-request'; // Load the config file. First try to load up a domain-specific config of the // form "config.$domain.json" and if that fails, fall back to config.json. -export async function getVectorConfig(relativeLocation) { - if (relativeLocation === undefined) relativeLocation = ''; +export async function getVectorConfig(relativeLocation: string='') { if (relativeLocation !== '' && !relativeLocation.endsWith('/')) relativeLocation += '/'; const specificConfigPromise = getConfig(`${relativeLocation}config.${document.domain}.json`); @@ -37,7 +36,7 @@ export async function getVectorConfig(relativeLocation) { } } -function getConfig(configJsonFilename) { +function getConfig(configJsonFilename: string): Promise<{}> { return new Promise(function(resolve, reject) { request( { method: "GET", url: configJsonFilename, qs: { cachebuster: Date.now() } }, diff --git a/src/vector/init.ts b/src/vector/init.ts index 96fd57b0..16a6a885 100644 --- a/src/vector/init.ts +++ b/src/vector/init.ts @@ -26,7 +26,7 @@ import * as languageHandler from 'matrix-react-sdk/src/languageHandler'; import SettingsStore from "matrix-react-sdk/src/settings/SettingsStore"; -export function loadOlm() { +export function loadOlm(): Promise { /* Load Olm. We try the WebAssembly version first, and then the legacy, * asm.js version if that fails. For this reason we need to wait for this * to finish before continuing to load the rest of the app. In future diff --git a/src/vector/rageshakesetup.js b/src/vector/rageshakesetup.ts similarity index 97% rename from src/vector/rageshakesetup.js rename to src/vector/rageshakesetup.ts index e9ce1c3b..6445f4e9 100644 --- a/src/vector/rageshakesetup.js +++ b/src/vector/rageshakesetup.ts @@ -50,7 +50,7 @@ function initRageshake() { initRageshake(); -global.mxSendRageshake = function(text, withLogs) { +window.mxSendRageshake = function(text: string, withLogs?: boolean) { if (withLogs === undefined) withLogs = true; if (!text || !text.trim()) { console.error("Cannot send a rageshake without a message - please tell us what went wrong"); diff --git a/src/vector/url_utils.ts b/src/vector/url_utils.ts index 935167aa..6a08ec75 100644 --- a/src/vector/url_utils.ts +++ b/src/vector/url_utils.ts @@ -20,7 +20,7 @@ import * as qs from 'querystring'; // so we're re-using query string like format // // returns {location, params} -export function parseQsFromFragment(location) { +export function parseQsFromFragment(location: Location) { // if we have a fragment, it will start with '#', which we need to drop. // (if we don't, this will return ''). const fragment = location.hash.substring(1); @@ -41,6 +41,6 @@ export function parseQsFromFragment(location) { return result; } -export function parseQs(location) { +export function parseQs(location: Location) { return qs.parse(location.search.substring(1)); }