From 8b403021835240c203d323f848b5fb104fd1d20f Mon Sep 17 00:00:00 2001 From: e-cloud Date: Fri, 4 Nov 2016 09:34:46 +0800 Subject: [PATCH 1/2] fix: update version number for source-map --- source-map/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source-map/index.d.ts b/source-map/index.d.ts index dfddb63e27..d7da94ff75 100644 --- a/source-map/index.d.ts +++ b/source-map/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for source-map v0.1.38 +// Type definitions for source-map v0.5.6 // Project: https://github.com/mozilla/source-map // Definitions by: Morten Houston Ludvigsen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 78098d48dfe83939979f1d8b9d3f310f68335460 Mon Sep 17 00:00:00 2001 From: e-cloud Date: Tue, 8 Nov 2016 11:07:53 +0800 Subject: [PATCH 2/2] fix: more accurate types and corresponding tests --- source-map/index.d.ts | 6 +++--- source-map/source-map-tests.ts | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/source-map/index.d.ts b/source-map/index.d.ts index d7da94ff75..8b8f800c85 100644 --- a/source-map/index.d.ts +++ b/source-map/index.d.ts @@ -58,7 +58,7 @@ declare namespace SourceMap { public static GENERATED_ORDER: number; public static ORIGINAL_ORDER: number; - constructor(rawSourceMap: RawSourceMap); + constructor(rawSourceMap: RawSourceMap | string); public computeColumnSpans(): void; @@ -115,9 +115,9 @@ declare namespace SourceMap { relativePath?: string ): SourceNode; - public add(chunk: any): SourceNode; + public add(chunk: (string | SourceNode)[] | SourceNode | string): SourceNode; - public prepend(chunk: any): SourceNode; + public prepend(chunk: (string | SourceNode)[] | SourceNode | string): SourceNode; public setSourceContent(sourceFile: string, sourceContent: string): void; diff --git a/source-map/source-map-tests.ts b/source-map/source-map-tests.ts index 23722d8179..4e584d2338 100644 --- a/source-map/source-map-tests.ts +++ b/source-map/source-map-tests.ts @@ -14,6 +14,15 @@ function testSourceMapConsumer() { file: 'sdf' }); + scm = new SourceMap.SourceMapConsumer(JSON.stringify({ + version: 3, + sources: ['foo', 'bar'], + names: ['foo', 'bar'], + sourcesContent: ['foo'], + mappings: 'foo', + file: 'sdf' + })); + // create with partial RawSourceMap scm = new SourceMap.SourceMapConsumer({ version: 3, @@ -129,10 +138,14 @@ function testSourceNode() { function testAdd(node: SourceMap.SourceNode) { node.add('foo'); + node.add(new SourceMap.SourceNode()); + node.add([new SourceMap.SourceNode(), 'bar']); } function testPrepend(node: SourceMap.SourceNode) { node.prepend('foo'); + node.prepend(new SourceMap.SourceNode()); + node.prepend([new SourceMap.SourceNode(), 'bar']); } function testSetSourceContent(node: SourceMap.SourceNode) {