/** Namespace that comprises various utils (also cleans up documentation). */ declare namespace fetch { interface FetchTransform { (data: any): T | undefined; } /** * Creates a promise for an asynchronous xml/http request on a given URL. If an URL is fetched successfully, the * promise is resolved with the fetched data. * @param url - Uniform resource locator string referencing a file. * @param type - Request response type. * @returns - A promise that resolves on a parsed object if successful. */ function fetchAsync(url: string, type: XMLHttpRequestResponseType): Promise; /** * Creates a promise for an asynchronous xml/http request on a given URL. If an URL is fetched successfully, the * promise is resolved with a parsed JSON object. An error code and message can be caught otherwise. * @param url - Uniform resource locator string referencing a JSON file. * @param transform - Callback to a function that transforms the fetched data into an instance of targeted type. * @param schema - Optional schema, that if specified, is used to validate the fetched json data. * @returns - A promise that resolves on a parsed JSON object if successful. */ function fetchJsonAsync(url: string, transform: FetchTransform, schema?: any): Promise; } export = fetch;