Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand typings for source-map-support. #2504

Merged
merged 1 commit into from
Jul 14, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 36 additions & 0 deletions source-map-support/source-map-support-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,39 @@
import sms = require('source-map-support');

sms.install();

function retrieveFile(path: string): string {
return "foo";
}

function retrieveSourceMap(source: string): sms.UrlAndMap {
return {
url: "http://foo",
map: "foo"
};
}

var options: sms.Options = {
emptyCacheBetweenOperations: false,
handleUncaughtExceptions: false,
retrieveFile: retrieveFile,
retrieveSourceMap: retrieveSourceMap
};

sms.install(options);

var stackFrame: any; // TODO: this should be a StackFrame, but it seems this would need to be defined elsewhere (in e.g. lib.d.ts)
stackFrame = sms.wrapCallSite(stackFrame);

var s: string;
s = sms.getErrorSource(new Error("foo"));

var p: sms.Position = {
column: 0,
line: 0,
source: "foo"
};
p = sms.mapSourcePosition(p);

var u: sms.UrlAndMap;
u = retrieveSourceMap("foo");
37 changes: 35 additions & 2 deletions source-map-support/source-map-support.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
// Type definitions for source-map-support 0.2.5
// Type definitions for source-map-support 0.2.6
// Project: https://github.com/evanw/source-map-support
// Definitions by: Bart van der Schoor <https://github.com/Bartvds>
// Definitions: https://github.com/borisyankov/DefinitelyTyped

declare module 'source-map-support' {
export function install(): any;
/**
* Output of retrieveSourceMap().
*/
export interface UrlAndMap {
url: string;
map: any; // string or Buffer
}

/**
* Options to install().
*/
export interface Options {
handleUncaughtExceptions?: boolean;
emptyCacheBetweenOperations?: boolean;
retrieveFile?: (path: string) => string;
retrieveSourceMap?: (source: string) => UrlAndMap;
}

export interface Position {
source: string;
line: number;
column: number;
}

export function wrapCallSite(frame: any /* StackFrame */): any /* StackFrame */;
export function getErrorSource(error: Error): string;
export function mapSourcePosition(position: Position): Position;
export function retrieveSourceMap(source: string): UrlAndMap;

/**
* Install SourceMap support.
* @param options Can be used to e.g. disable uncaughtException handler.
*/
export function install(options?: Options): void;
}