diff --git a/types/source-map-support/index.d.ts b/types/source-map-support/index.d.ts index 8df4456483..3898c471a2 100644 --- a/types/source-map-support/index.d.ts +++ b/types/source-map-support/index.d.ts @@ -1,11 +1,10 @@ -// Type definitions for source-map-support 0.2.10 +// Type definitions for source-map-support 0.4 // Project: https://github.com/evanw/source-map-support -// Definitions by: Bart van der Schoor +// Definitions by: Bart van der Schoor , Jason Cheatham // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// - /** * Output of retrieveSourceMap(). */ @@ -19,9 +18,13 @@ export interface UrlAndMap { */ export interface Options { handleUncaughtExceptions?: boolean; + hookRequire?: boolean; emptyCacheBetweenOperations?: boolean; - retrieveFile?: (path: string) => string; - retrieveSourceMap?: (source: string) => UrlAndMap; + environment?: 'auto' | 'browser' | 'node'; + overrideRetrieveFile?: boolean; + overrideRetrieveSourceMap?: boolean; + retrieveFile?(path: string): string; + retrieveSourceMap?(source: string): UrlAndMap; } export interface Position { @@ -30,13 +33,13 @@ export interface Position { column: number; } -export declare function wrapCallSite(frame: any /* StackFrame */): any /* StackFrame */; -export declare function getErrorSource(error: Error): string; -export declare function mapSourcePosition(position: Position): Position; -export declare function retrieveSourceMap(source: string): UrlAndMap; +export function wrapCallSite(frame: any /* StackFrame */): any /* StackFrame */; +export function getErrorSource(error: Error): string | null; +export function mapSourcePosition(position: Position): Position; +export function retrieveSourceMap(source: string): UrlAndMap | null; /** * Install SourceMap support. * @param options Can be used to e.g. disable uncaughtException handler. */ -export declare function install(options?: Options): void; +export function install(options?: Options): void; diff --git a/types/source-map-support/source-map-support-tests.ts b/types/source-map-support/source-map-support-tests.ts index 602547509e..9a30b6a68f 100644 --- a/types/source-map-support/source-map-support-tests.ts +++ b/types/source-map-support/source-map-support-tests.ts @@ -1,4 +1,3 @@ - import sms = require('source-map-support'); sms.install(); @@ -14,27 +13,31 @@ function retrieveSourceMap(source: string): sms.UrlAndMap { }; } -var options: sms.Options = { +const options: sms.Options = { emptyCacheBetweenOperations: false, handleUncaughtExceptions: false, - retrieveFile: retrieveFile, - retrieveSourceMap: retrieveSourceMap + retrieveFile, + retrieveSourceMap, + environment: 'node', + hookRequire: false, + overrideRetrieveSourceMap: false, + overrideRetrieveFile: false }; 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) +let 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; +let s: string | null; s = sms.getErrorSource(new Error("foo")); -var p: sms.Position = { +let p: sms.Position = { column: 0, line: 0, source: "foo" }; p = sms.mapSourcePosition(p); -var u: sms.UrlAndMap; +let u: sms.UrlAndMap; u = retrieveSourceMap("foo"); diff --git a/types/source-map-support/tsconfig.json b/types/source-map-support/tsconfig.json index 8a90e5ecec..3f07ef5207 100644 --- a/types/source-map-support/tsconfig.json +++ b/types/source-map-support/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -19,4 +19,4 @@ "index.d.ts", "source-map-support-tests.ts" ] -} \ No newline at end of file +} diff --git a/types/source-map-support/tslint.json b/types/source-map-support/tslint.json new file mode 100644 index 0000000000..d88586e5bd --- /dev/null +++ b/types/source-map-support/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}