diff --git a/package-lock.json b/package-lock.json index c1010e870..96ebe16dc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -146,9 +146,11 @@ "@types/js-md5": "0.4.3", "@types/lodash": "4.14.182", "@types/react": "17.0.14", - "@types/react-native": "0.67.6", + "@types/react-native": "0.68.1", "@types/react-redux": "7.1.24", + "@types/unorm": "1.3.28", "@types/uuid": "8.3.4", + "@types/zxcvbn": "4.4.1", "@typescript-eslint/eslint-plugin": "5.30.5", "@typescript-eslint/parser": "5.30.4", "babel-loader": "8.2.3", @@ -5653,9 +5655,9 @@ } }, "node_modules/@types/react-native": { - "version": "0.67.6", - "resolved": "https://registry.npmjs.org/@types/react-native/-/react-native-0.67.6.tgz", - "integrity": "sha512-NM6atxrefIXMLE/PyQ1bIQjQ/lWLdls3uVxItzKvNUUVZlGqgn/uGN4MarM9quSf90uSqJYPIAeAgTtBTUjhgg==", + "version": "0.68.1", + "resolved": "https://registry.npmjs.org/@types/react-native/-/react-native-0.68.1.tgz", + "integrity": "sha512-S+r6VamWqVutlQ3q/vhTn4b0F/DdZj8R6AIDdgwV9xN9Ln1kRdQd7o3mo7FnfdddVdzEkWMUVlK2sbkFOJFAiQ==", "dev": true, "dependencies": { "@types/react": "*" @@ -5725,6 +5727,12 @@ "@types/node": "*" } }, + "node_modules/@types/unorm": { + "version": "1.3.28", + "resolved": "https://registry.npmjs.org/@types/unorm/-/unorm-1.3.28.tgz", + "integrity": "sha512-l3uh18vcvkQ964HSK7Tx0YbhxN/Hj+k1w3nLT08n770lngqVKljmF7Ht4e7elFbx6L2WYse97whtpJOo8MHtxQ==", + "dev": true + }, "node_modules/@types/uuid": { "version": "8.3.4", "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", @@ -5758,6 +5766,12 @@ "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-20.2.1.tgz", "integrity": "sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw==" }, + "node_modules/@types/zxcvbn": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@types/zxcvbn/-/zxcvbn-4.4.1.tgz", + "integrity": "sha512-3NoqvZC2W5gAC5DZbTpCeJ251vGQmgcWIHQJGq2J240HY6ErQ9aWKkwfoKJlHLx+A83WPNTZ9+3cd2ILxbvr1w==", + "dev": true + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "5.30.5", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.30.5.tgz", @@ -24977,9 +24991,9 @@ } }, "@types/react-native": { - "version": "0.67.6", - "resolved": "https://registry.npmjs.org/@types/react-native/-/react-native-0.67.6.tgz", - "integrity": "sha512-NM6atxrefIXMLE/PyQ1bIQjQ/lWLdls3uVxItzKvNUUVZlGqgn/uGN4MarM9quSf90uSqJYPIAeAgTtBTUjhgg==", + "version": "0.68.1", + "resolved": "https://registry.npmjs.org/@types/react-native/-/react-native-0.68.1.tgz", + "integrity": "sha512-S+r6VamWqVutlQ3q/vhTn4b0F/DdZj8R6AIDdgwV9xN9Ln1kRdQd7o3mo7FnfdddVdzEkWMUVlK2sbkFOJFAiQ==", "dev": true, "requires": { "@types/react": "*" @@ -25049,6 +25063,12 @@ "@types/node": "*" } }, + "@types/unorm": { + "version": "1.3.28", + "resolved": "https://registry.npmjs.org/@types/unorm/-/unorm-1.3.28.tgz", + "integrity": "sha512-l3uh18vcvkQ964HSK7Tx0YbhxN/Hj+k1w3nLT08n770lngqVKljmF7Ht4e7elFbx6L2WYse97whtpJOo8MHtxQ==", + "dev": true + }, "@types/uuid": { "version": "8.3.4", "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", @@ -25082,6 +25102,12 @@ "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-20.2.1.tgz", "integrity": "sha512-7tFImggNeNBVMsn0vLrpn1H1uPrUBdnARPTpZoitY37ZrdJREzf7I16tMrlK3hen349gr1NYh8CmZQa7CTG6Aw==" }, + "@types/zxcvbn": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@types/zxcvbn/-/zxcvbn-4.4.1.tgz", + "integrity": "sha512-3NoqvZC2W5gAC5DZbTpCeJ251vGQmgcWIHQJGq2J240HY6ErQ9aWKkwfoKJlHLx+A83WPNTZ9+3cd2ILxbvr1w==", + "dev": true + }, "@typescript-eslint/eslint-plugin": { "version": "5.30.5", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-5.30.5.tgz", diff --git a/package.json b/package.json index b07b4a997..29544aeaa 100644 --- a/package.json +++ b/package.json @@ -151,9 +151,11 @@ "@types/js-md5": "0.4.3", "@types/lodash": "4.14.182", "@types/react": "17.0.14", - "@types/react-native": "0.67.6", + "@types/react-native": "0.68.1", "@types/react-redux": "7.1.24", + "@types/unorm": "1.3.28", "@types/uuid": "8.3.4", + "@types/zxcvbn": "4.4.1", "@typescript-eslint/eslint-plugin": "5.30.5", "@typescript-eslint/parser": "5.30.4", "babel-loader": "8.2.3", diff --git a/react/features/base/environment/environment.js b/react/features/base/environment/environment.ts similarity index 90% rename from react/features/base/environment/environment.js rename to react/features/base/environment/environment.ts index 3b6a808ef..c1bc09287 100644 --- a/react/features/base/environment/environment.js +++ b/react/features/base/environment/environment.ts @@ -1,7 +1,6 @@ -// @flow - +// @ts-ignore import JitsiMeetJS from '../lib-jitsi-meet'; -import Platform from '../react/Platform'; +import Platform from '../react/Platform.web'; import { isMobileBrowser } from './utils'; @@ -15,7 +14,7 @@ const DEFAULT_OPTIMAL_BROWSERS = [ 'safari' ]; -const DEFAULT_UNSUPPORTED_BROWSERS = []; +const DEFAULT_UNSUPPORTED_BROWSERS: string[] = []; const browserNameToCheck = { chrome: browser.isChrome.bind(browser), @@ -27,7 +26,8 @@ const browserNameToCheck = { safari: browser.isSafari.bind(browser) }; -declare var interfaceConfig: Object; +// eslint-disable-next-line no-var +declare var interfaceConfig: any; /** * Returns whether or not jitsi is optimized and targeted for the provided @@ -117,9 +117,9 @@ export function isSupportedMobileBrowser() { * @private * @returns {boolean} */ -function _isCurrentBrowserInList(list) { +function _isCurrentBrowserInList(list: string[]) { return Boolean(list.find(browserName => { - const checkFunction = browserNameToCheck[browserName]; + const checkFunction = browserNameToCheck[browserName as keyof typeof browserNameToCheck]; return checkFunction ? checkFunction.call(browser) : false; })); diff --git a/react/features/base/react/Platform.web.js b/react/features/base/react/Platform.web.ts similarity index 98% rename from react/features/base/react/Platform.web.js rename to react/features/base/react/Platform.web.ts index 127de2e9f..9a65d2ebb 100644 --- a/react/features/base/react/Platform.web.js +++ b/react/features/base/react/Platform.web.ts @@ -1,5 +1,4 @@ -/* @flow */ - +// @ts-ignore const { userAgent, maxTouchPoints, platform } = navigator; let OS; diff --git a/react/features/base/user-interaction/middleware.js b/react/features/base/user-interaction/middleware.ts similarity index 81% rename from react/features/base/user-interaction/middleware.js rename to react/features/base/user-interaction/middleware.ts index eb5600492..3124b8652 100644 --- a/react/features/base/user-interaction/middleware.js +++ b/react/features/base/user-interaction/middleware.ts @@ -1,7 +1,5 @@ -// @flow - -import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app'; -import { MiddlewareRegistry } from '../redux'; +import { APP_WILL_MOUNT, APP_WILL_UNMOUNT } from '../app/actionTypes'; +import MiddlewareRegistry from '../redux/MiddlewareRegistry'; import { USER_INTERACTION_RECEIVED } from './actionTypes'; @@ -11,7 +9,7 @@ import { USER_INTERACTION_RECEIVED } from './actionTypes'; * * @type {Function|null} */ -let userInteractionListener = null; +let userInteractionListener: Function|null = null; /** * Implements the entry point of the middleware of the feature base/user-interaction. @@ -41,7 +39,7 @@ MiddlewareRegistry.register(store => next => action => { * @private * @returns {void} */ -function _onUserInteractionReceived(dispatch, event) { +function _onUserInteractionReceived(dispatch: Function, event: any) { if (event.isTrusted) { dispatch({ type: USER_INTERACTION_RECEIVED @@ -58,12 +56,15 @@ function _onUserInteractionReceived(dispatch, event) { * @private * @returns {void} */ -function _startListeningForUserInteraction({ dispatch }) { +function _startListeningForUserInteraction({ dispatch }: {dispatch: Function}) { _stopListeningForUserInteraction(); userInteractionListener = _onUserInteractionReceived.bind(null, dispatch); + // @ts-ignore window.addEventListener('mousedown', userInteractionListener); + + // @ts-ignore window.addEventListener('keydown', userInteractionListener); } @@ -74,7 +75,10 @@ function _startListeningForUserInteraction({ dispatch }) { * @returns {void} */ function _stopListeningForUserInteraction() { + // @ts-ignore window.removeEventListener('mousedown', userInteractionListener); + + // @ts-ignore window.removeEventListener('keydown', userInteractionListener); userInteractionListener = null; diff --git a/react/features/base/util/downloadJSON.js b/react/features/base/util/downloadJSON.ts similarity index 98% rename from react/features/base/util/downloadJSON.js rename to react/features/base/util/downloadJSON.ts index 8c4956988..d85a101d9 100644 --- a/react/features/base/util/downloadJSON.js +++ b/react/features/base/util/downloadJSON.ts @@ -1,5 +1,3 @@ -// @flow - /** * Downloads a JSON object. * diff --git a/react/features/base/util/helpers.js b/react/features/base/util/helpers.ts similarity index 91% rename from react/features/base/util/helpers.js rename to react/features/base/util/helpers.ts index a01cd8780..13838430b 100644 --- a/react/features/base/util/helpers.js +++ b/react/features/base/util/helpers.ts @@ -1,5 +1,3 @@ -// @flow - import clipboardCopy from 'clipboard-copy'; /** @@ -15,7 +13,7 @@ export function assignIfDefined(target: Object, source: Object) { for (const nextKey in source) { if (source.hasOwnProperty(nextKey)) { - const value = source[nextKey]; + const value = source[nextKey as keyof typeof source]; if (typeof value !== 'undefined') { to[nextKey] = value; @@ -49,7 +47,7 @@ export async function copyText(textToCopy: string) { * @returns {{promise, resolve, reject}} */ export function createDeferred(): Object { - const deferred = {}; + const deferred: any = {}; deferred.promise = new Promise((resolve, reject) => { deferred.resolve = resolve; @@ -83,7 +81,7 @@ export function escapeRegexp(s: string) { * @param {Object} w - Window object to use instead of the built in one. * @returns {string} */ -export function getBaseUrl(w: Object = window) { +export function getBaseUrl(w: Window = window) { const doc = w.document; const base = doc.querySelector('base'); @@ -104,14 +102,19 @@ export function getBaseUrl(w: Object = window) { * NOTE: After React-ifying everything this should be the only global. */ export function getJitsiMeetGlobalNS() { + // @ts-ignore if (!window.JitsiMeetJS) { + // @ts-ignore window.JitsiMeetJS = {}; } + // @ts-ignore if (!window.JitsiMeetJS.app) { + // @ts-ignore window.JitsiMeetJS.app = {}; } + // @ts-ignore return window.JitsiMeetJS.app; } @@ -122,9 +125,9 @@ export function getJitsiMeetGlobalNS() { * @param {string} msg - A custom message to print in addition to the error. * @returns {void} */ -export function reportError(e: Object, msg: string = '') { +export function reportError(e: Error, msg = '') { console.error(msg, e); - window.onerror && window.onerror(msg, null, null, null, e); + window.onerror && window.onerror(msg, undefined, undefined, undefined, e); } /** @@ -168,7 +171,7 @@ export function setColorAlpha(color: string, opacity: number) { * @param {string} color - * @returns {Array} - Array containing parsed r, g, b values of the color. */ -function parseShorthandColor(color) { +function parseShorthandColor(color: string) { let b, g, r; r = color.substring(1, 2); diff --git a/react/features/base/util/hooks.js b/react/features/base/util/hooks.ts similarity index 97% rename from react/features/base/util/hooks.js rename to react/features/base/util/hooks.ts index c5a1dd77e..921bc88f7 100644 --- a/react/features/base/util/hooks.js +++ b/react/features/base/util/hooks.ts @@ -1,4 +1,3 @@ -// @flow import { useSelector } from 'react-redux'; /** diff --git a/react/features/base/util/httpUtils.js b/react/features/base/util/httpUtils.ts similarity index 94% rename from react/features/base/util/httpUtils.js rename to react/features/base/util/httpUtils.ts index 5692d3d36..94b7c176b 100644 --- a/react/features/base/util/httpUtils.js +++ b/react/features/base/util/httpUtils.ts @@ -17,7 +17,7 @@ const RETRY_TIMEOUT = 3000; * @returns {Promise} The response body, in JSON format, will be * through the Promise. */ -export function doGetJSON(url, retry, options) { +export function doGetJSON(url: string, retry?: boolean, options?: Object) { const fetchPromise = fetch(url, options) .then(response => { const jsonify = response.json(); diff --git a/react/features/base/util/isInsecureRoomName.js b/react/features/base/util/isInsecureRoomName.ts similarity index 85% rename from react/features/base/util/isInsecureRoomName.js rename to react/features/base/util/isInsecureRoomName.ts index c6edec734..b73a39865 100644 --- a/react/features/base/util/isInsecureRoomName.js +++ b/react/features/base/util/isInsecureRoomName.ts @@ -1,5 +1,3 @@ -// @flow - import _ from 'lodash'; import { NIL, parse as parseUUID } from 'uuid'; import zxcvbn from 'zxcvbn'; @@ -13,7 +11,7 @@ const NIL_UUID = parseUUID(NIL); * @param {string} str - The string to be checked. * @returns {boolean} - Whether the string is a valid UUID or not. */ -function isValidUUID(str) { +function isValidUUID(str: string) { let uuid; try { @@ -31,6 +29,6 @@ function isValidUUID(str) { * @param {string} roomName - The room name. * @returns {boolean} */ -export default function isInsecureRoomName(roomName: string = ''): boolean { +export default function isInsecureRoomName(roomName = ''): boolean { return !isValidUUID(roomName) && zxcvbn(roomName).score < 3; } diff --git a/react/features/base/util/loadScript.native.js b/react/features/base/util/loadScript.native.ts similarity index 97% rename from react/features/base/util/loadScript.native.js rename to react/features/base/util/loadScript.native.ts index 63aa193a1..46d4d4c57 100644 --- a/react/features/base/util/loadScript.native.js +++ b/react/features/base/util/loadScript.native.ts @@ -1,5 +1,3 @@ -// @flow - /** * Default timeout for loading scripts. */ @@ -20,7 +18,7 @@ const DEFAULT_TIMEOUT = 5000; * @returns {void} */ export async function loadScript( - url: string, timeout: number = DEFAULT_TIMEOUT, skipEval: boolean = false): Promise { + url: string, timeout: number = DEFAULT_TIMEOUT, skipEval = false): Promise { // XXX The implementation of fetch on Android will throw an Exception on // the Java side which will break the app if the URL is invalid (which // the implementation of fetch on Android calls 'unexpected url'). In diff --git a/react/features/base/util/loadScript.web.js b/react/features/base/util/loadScript.web.ts similarity index 90% rename from react/features/base/util/loadScript.web.js rename to react/features/base/util/loadScript.web.ts index f03a9d77a..2f5f92e25 100644 --- a/react/features/base/util/loadScript.web.js +++ b/react/features/base/util/loadScript.web.ts @@ -1,6 +1,5 @@ -// @flow - -declare var JitsiMeetJS: Object; +// eslint-disable-next-line no-var +declare var JitsiMeetJS: any; /** * Loads a script from a specific URL. The script will be interpreted upon load. diff --git a/react/features/base/util/openURLInBrowser.native.js b/react/features/base/util/openURLInBrowser.native.ts similarity index 96% rename from react/features/base/util/openURLInBrowser.native.js rename to react/features/base/util/openURLInBrowser.native.ts index de12b5fbb..775322078 100644 --- a/react/features/base/util/openURLInBrowser.native.js +++ b/react/features/base/util/openURLInBrowser.native.ts @@ -1,7 +1,6 @@ -// @flow - import { Linking } from 'react-native'; +// @ts-ignore import logger from './logger'; /** diff --git a/react/features/base/util/openURLInBrowser.web.js b/react/features/base/util/openURLInBrowser.web.ts similarity index 97% rename from react/features/base/util/openURLInBrowser.web.js rename to react/features/base/util/openURLInBrowser.web.ts index c1572ad13..4f4e30135 100644 --- a/react/features/base/util/openURLInBrowser.web.js +++ b/react/features/base/util/openURLInBrowser.web.ts @@ -1,5 +1,3 @@ -// @flow - /** * Opens URL in the browser. * diff --git a/react/features/base/util/parseURLParams.js b/react/features/base/util/parseURLParams.ts similarity index 93% rename from react/features/base/util/parseURLParams.js rename to react/features/base/util/parseURLParams.ts index 11494e405..e67bc2219 100644 --- a/react/features/base/util/parseURLParams.js +++ b/react/features/base/util/parseURLParams.ts @@ -1,5 +1,4 @@ -/* @flow */ - +// @ts-ignore import Bourne from '@hapi/bourne'; import { reportError } from './helpers'; @@ -24,14 +23,14 @@ const blacklist = [ '__proto__', 'constructor', 'prototype' ]; */ export function parseURLParams( url: URL | string, - dontParse: boolean = false, - source: string = 'hash'): Object { + dontParse = false, + source = 'hash'): Object { if (typeof url === 'string') { // eslint-disable-next-line no-param-reassign url = new URL(url); } const paramStr = source === 'search' ? url.search : url.hash; - const params = {}; + const params: any = {}; const paramParts = (paramStr && paramStr.substr(1).split('&')) || []; // Detect and ignore hash params for hash routers. @@ -61,7 +60,7 @@ export function parseURLParams( value = decoded === 'undefined' ? undefined : Bourne.parse(decoded); } - } catch (e) { + } catch (e: any) { reportError( e, `Failed to parse URL parameter value: ${String(value)}`); diff --git a/react/features/base/util/react-focus-lock-wrapper.js b/react/features/base/util/react-focus-lock-wrapper.js index f55b6c18e..f71733fc8 100644 --- a/react/features/base/util/react-focus-lock-wrapper.js +++ b/react/features/base/util/react-focus-lock-wrapper.js @@ -10,7 +10,7 @@ import FocusLock, { MoveFocusInside } from 'react-focus-lock'; * @param {Object} props - The props passed to the FocusLock. * @returns {ReactElement} */ -export default (props: Object) => { +export default (props: any) => { const { children, ...otherProps } = props; const forwardProps = { diff --git a/react/features/base/util/strings.native.js b/react/features/base/util/strings.native.ts similarity index 98% rename from react/features/base/util/strings.native.js rename to react/features/base/util/strings.native.ts index f7595dab8..619a36b38 100644 --- a/react/features/base/util/strings.native.js +++ b/react/features/base/util/strings.native.ts @@ -1,5 +1,3 @@ -// @flow - import * as unorm from 'unorm'; /** diff --git a/react/features/base/util/strings.web.js b/react/features/base/util/strings.web.ts similarity index 98% rename from react/features/base/util/strings.web.js rename to react/features/base/util/strings.web.ts index 5113c33d4..3bf703627 100644 --- a/react/features/base/util/strings.web.js +++ b/react/features/base/util/strings.web.ts @@ -1,5 +1,3 @@ -// @flow - /** * Applies NFKC normalization to the given text. * diff --git a/react/features/base/util/timeoutPromise.js b/react/features/base/util/timeoutPromise.ts similarity index 99% rename from react/features/base/util/timeoutPromise.js rename to react/features/base/util/timeoutPromise.ts index 012452932..7164b0176 100644 --- a/react/features/base/util/timeoutPromise.js +++ b/react/features/base/util/timeoutPromise.ts @@ -1,5 +1,3 @@ -// @flow - /** * Returns a new {@code Promise} which settles when a specific {@code Promise} * settles and is automatically rejected if the specified {@code Promise} diff --git a/react/features/base/util/uri.js b/react/features/base/util/uri.ts similarity index 94% rename from react/features/base/util/uri.js rename to react/features/base/util/uri.ts index 8cafc59ee..a0c3403e1 100644 --- a/react/features/base/util/uri.js +++ b/react/features/base/util/uri.ts @@ -1,6 +1,6 @@ -// @flow - import { parseURLParams } from './parseURLParams'; +// eslint-disable-next-line lines-around-comment +// @ts-ignore import { normalizeNFKC } from './strings'; /** @@ -53,7 +53,7 @@ export const URI_PROTOCOL_PATTERN = '^([a-z][a-z0-9\\.\\+-]*:)'; * @private * @returns {?string} */ -function _fixPathPart(pathPart: ?string) { +function _fixPathPart(pathPart?: string) { return pathPart ? pathPart.replace(new RegExp(_ROOM_EXCLUDE_PATTERN, 'g'), '') : pathPart; @@ -107,7 +107,7 @@ function _fixURIStringScheme(uri: string) { * @param {string?} path - The path to convert. * @returns {string?} */ -export function getBackendSafePath(path: ?string): ?string { +export function getBackendSafePath(path?: string): string|undefined { if (!path) { return path; } @@ -124,7 +124,7 @@ export function getBackendSafePath(path: ?string): ?string { * @param {string?} room - The room name to convert. * @returns {string?} */ -export function getBackendSafeRoomName(room: ?string): ?string { +export function getBackendSafeRoomName(room?: string): string|undefined { if (!room) { return room; } @@ -146,10 +146,10 @@ export function getBackendSafeRoomName(room: ?string): ?string { room = normalizeNFKC(room); // Only decoded and normalized strings can be lowercased properly. - room = room.toLowerCase(); + room = room?.toLowerCase(); // But we still need to (re)encode it. - room = encodeURIComponent(room); + room = encodeURIComponent(room ?? ''); /* eslint-enable no-param-reassign */ // Unfortunately we still need to lowercase it, because encoding a string will @@ -192,7 +192,7 @@ function _objectToURLParamsArray(obj = {}) { for (const key in obj) { // eslint-disable-line guard-for-in try { params.push( - `${key}=${encodeURIComponent(JSON.stringify(obj[key]))}`); + `${key}=${encodeURIComponent(JSON.stringify(obj[key as keyof typeof obj]))}`); } catch (e) { console.warn(`Error encoding ${key}: ${e}`); } @@ -221,7 +221,7 @@ function _objectToURLParamsArray(obj = {}) { export function parseStandardURIString(str: string) { /* eslint-disable no-param-reassign */ - const obj: Object = { + const obj: {[key: string]: any} = { toString: _standardURIToString }; @@ -258,6 +258,7 @@ export function parseStandardURIString(str: string) { authority = authority.substring(userinfoEndIndex + 1); } + // @ts-ignore obj.host = authority; // port @@ -276,7 +277,7 @@ export function parseStandardURIString(str: string) { regex = new RegExp(`^${_URI_PATH_PATTERN}`, 'gi'); match = regex.exec(str); - let pathname: ?string; + let pathname: string|undefined; if (match) { pathname = match[1]; @@ -329,7 +330,7 @@ export function parseStandardURIString(str: string) { * search: string * }} */ -export function parseURIString(uri: ?string) { +export function parseURIString(uri?: string) { if (typeof uri !== 'string') { return undefined; } @@ -338,13 +339,14 @@ export function parseURIString(uri: ?string) { // XXX While the components/segments of pathname are URI encoded, Jitsi Meet // on the client and/or server sides still don't support certain characters. - obj.pathname = obj.pathname.split('/').map(pathPart => _fixPathPart(pathPart)) + obj.pathname = obj.pathname.split('/').map((pathPart: any) => _fixPathPart(pathPart)) .join('/'); // Add the properties that are specific to a Jitsi Meet resource (location) // such as contextRoot, room: // contextRoot + // @ts-ignore obj.contextRoot = getLocationContextRoot(obj); // The room (name) is the last component/segment of pathname. @@ -371,7 +373,8 @@ export function parseURIString(uri: ?string) { * function is invoked on such an instance. * @returns {string} */ -function _standardURIToString(thiz: ?Object) { +function _standardURIToString(thiz?: Object) { + // @ts-ignore // eslint-disable-next-line no-invalid-this const { hash, host, pathname, protocol, search } = thiz || this; let str = ''; @@ -418,7 +421,7 @@ export function safeDecodeURIComponent(text: string) { * @returns {string} - A {@code String} representation of the specified * {@code obj} which is supposed to represent a URL. */ -export function toURLString(obj: ?(Object | string)): ?string { +export function toURLString(obj?: (Object | string)): string|undefined|null { let str; switch (typeof obj) { @@ -449,7 +452,7 @@ export function toURLString(obj: ?(Object | string)): ?string { * @returns {string} - A {@code String} representation of the specified * {@code Object}. */ -export function urlObjectToString(o: Object): ?string { +export function urlObjectToString(o: {[key: string]: any}): string|undefined { // First normalize the given url. It come as o.url or split into o.serverURL // and o.room. let tmp; @@ -466,7 +469,7 @@ export function urlObjectToString(o: Object): ?string { // protocol if (!url.protocol) { - let protocol: ?string = o.protocol || o.scheme; + let protocol: string|undefined = o.protocol || o.scheme; if (protocol) { // Protocol is supposed to be the scheme and the final ':'. Anyway, @@ -484,7 +487,7 @@ export function urlObjectToString(o: Object): ?string { // // It may be host/hostname and pathname with the latter denoting the // tenant. - const domain: ?string = o.domain || o.host || o.hostname; + const domain: string|undefined = o.domain || o.host || o.hostname; if (domain) { const { host, hostname, pathname: contextRoot, port }