DefinitelyTyped/types/browser-resolve/index.d.ts
Piotr Błażejewicz (Peter Blazejewicz) 5ed9dc7696
update(browser-resolve): align with v1.11 (#42807)
- add version to TS Header
- align package configuration
- align package definition with the orignal package details:
https://github.com/defunctzombie/node-browser-resolve/blob/master/index.js
- remove 3-slashes reference as duplicate
- minor refine for `callback` `error` parameter (can be null as per
usage)
- update authors
- update tests

https://github.com/defunctzombie/node-browser-resolve#api

Thanks!
2020-03-14 18:24:15 -07:00

63 lines
1.8 KiB
TypeScript

// Type definitions for browser-resolve 1.11
// Project: https://github.com/defunctzombie/node-browser-resolve
// Definitions by: Mario Nebl <https://github.com/marionebl>
// Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import * as resv from 'resolve';
/**
* Resolve a module path and call cb(err, path)
*
* @param id Identifier to resolve
* @param callback
*/
declare function resolve(id: string, cb: resolve.Callback): void;
/**
* Resolve a module path and call cb(err, path)
*
* @param id Identifier to resolve
* @param options Options to use for resolving, optional.
* @param callback
*/
declare function resolve(id: string, opts: resolve.AsyncOpts, cb: resolve.Callback): void;
declare namespace resolve {
interface Opts {
/**
* the 'browser' property to use from package.json
* @default 'browser'
*/
browser?: string;
/**
* the calling filename where the require() call originated (in the source)
*/
filename?: string;
/**
* modules object with id to path mappings to consult before doing manual resolution
* (use to provide core modules)
*/
modules?: any;
}
type AsyncOpts = resv.AsyncOpts & Opts;
type SyncOpts = resv.SyncOpts & Opts;
/**
* Callback invoked when resolving asynchronously
* @param error
* @param resolved Absolute path to resolved identifier
*/
type Callback = (err: Error | null, resolved?: string) => void;
/**
* Returns a module path
* @param id Identifier to resolve
* @param options Options to use for resolving.
*/
function sync(id: string, opts?: SyncOpts): string;
}
export = resolve;