/** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import type { AttemptOptions } from '../types.js'; /** * Detects promise-like values returned by internal loaders and callbacks. */ export declare function isPromise(value: T | Promise): value is Promise; type SwallowingAttemptOptions = AttemptOptions; type RethrowingAttemptOptions = AttemptOptions; /** * Runs a callback and normalizes sync and async error/finally handling. * * @remarks * - If try succeeds, its result is returned. * - If try fails and catch is omitted, the original error is propagated. * - If try fails and catch throws, that error is propagated. * - If try fails and catch completes normally, the failure is treated as swallowed * and attempt returns or resolves to undefined. * - catch is side-effect only; any value it returns is ignored. * - Type narrowing is based on whether catch is omitted or its declared return type: * omitted or never means the error is rethrown, void means the error may be swallowed. * - finally runs once for both sync and async paths. */ export declare function attempt(options: RethrowingAttemptOptions): TResult; export declare function attempt(options: RethrowingAttemptOptions>): Promise; export declare function attempt(options: SwallowingAttemptOptions): TResult | undefined; export declare function attempt(options: SwallowingAttemptOptions>): Promise; export {};