Skip to content

Commit a5f7f19

Browse files
committedMay 5, 2015
feat(tsfmt): support typescript@1.5.0-beta
1 parent a621319 commit a5f7f19

File tree

8 files changed

+773
-504
lines changed

8 files changed

+773
-504
lines changed
 

‎dtsm.json

+5-8
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,16 @@
99
"bundle": "typings/bundle.d.ts",
1010
"dependencies": {
1111
"node/node.d.ts": {
12-
"ref": "32f0a90dab26f70b206407ac24d4d622d0f0f408"
13-
},
14-
"typescript/typescript.d.ts": {
15-
"ref": "32f0a90dab26f70b206407ac24d4d622d0f0f408"
12+
"ref": "575d70adcad0086ec8c6f672a5eb569a4689486c"
1613
},
1714
"es6-promise/es6-promise.d.ts": {
18-
"ref": "32f0a90dab26f70b206407ac24d4d622d0f0f408"
15+
"ref": "575d70adcad0086ec8c6f672a5eb569a4689486c"
1916
},
2017
"mocha/mocha.d.ts": {
21-
"ref": "32f0a90dab26f70b206407ac24d4d622d0f0f408"
18+
"ref": "575d70adcad0086ec8c6f672a5eb569a4689486c"
2219
},
2320
"power-assert/power-assert.d.ts": {
24-
"ref": "32f0a90dab26f70b206407ac24d4d622d0f0f408"
21+
"ref": "575d70adcad0086ec8c6f672a5eb569a4689486c"
2522
}
2623
}
27-
}
24+
}

‎lib/formatter.ts

+17-5
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ import utils = require("./utils");
55

66
// from https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API#pretty-printer-using-the-ls-formatter
77

8-
// Note: this uses ts.formatting which is part of the typescript 1.4 package but is not currently
9-
// exposed in the public typescript.d.ts. The typings should be exposed in the next release.
8+
// Note: this uses ts.formatting which is part of the typescript 1.4 package but is not currently
9+
// exposed in the public typescript.d.ts. The typings should be exposed in the next release.
1010
function format(text:string, options = utils.createDefaultFormatCodeOptions()) {
1111
"use strict";
1212

1313
// Parse the source text
14-
var sourceFile = ts.createSourceFile("file.ts", text, ts.ScriptTarget.Latest, "0");
14+
var sourceFile = ts.createSourceFile("file.ts", text, ts.ScriptTarget.Latest, (<any>/* backward compat for typescript-1.4.1 */"0"));
1515
fixupParentReferences(sourceFile);
1616

1717
// Get the formatting edits on the input sources
@@ -33,8 +33,20 @@ function format(text:string, options = utils.createDefaultFormatCodeOptions()) {
3333
var result = text;
3434
for (var i = edits.length - 1; i >= 0; i--) {
3535
var change = edits[i];
36-
var head = result.slice(0, change.span.start());
37-
var tail = result.slice(change.span.start() + change.span.length());
36+
var head: string;
37+
if (typeof change.span.start === "number") {
38+
head = result.slice(0, change.span.start);
39+
} else {
40+
// backward compat for typescript-1.4.1
41+
head = result.slice(0, (<any>change.span.start)());
42+
}
43+
var tail: string;
44+
if (typeof change.span.start === "number") {
45+
tail = result.slice(change.span.start + change.span.length);
46+
} else {
47+
// backward compat for typescript-1.4.1
48+
tail = result.slice((<any>change.span.start)() + (<any>change.span.length)());
49+
}
3850
result = head + change.newText + tail;
3951
}
4052
return result;

‎lib/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/// <reference path="../typings/node/node.d.ts" />
2-
/// <reference path="../typings/typescript/typescript.d.ts" />
2+
/// <reference path="../node_modules/typescript/bin/typescript.d.ts" />
33

44
"use strict";
55

‎npm-shrinkwrap.json

+690-477
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@
3333
"dependencies": {
3434
"commandpost": "0.1.1",
3535
"editorconfig": "0.12.2",
36-
"es6-promise": "2.0.1",
37-
"typescript": "1.4.1"
36+
"es6-promise": "2.1.1",
37+
"typescript": "1.5.0-beta"
3838
},
3939
"devDependencies": {
4040
"espower-loader": "0.10.0",
4141
"grunt": "0.4.5",
4242
"grunt-contrib-clean": "0.6.0",
43-
"grunt-conventional-changelog": "^1.1.0",
43+
"grunt-conventional-changelog": "1.2.2",
4444
"grunt-dts-bundle": "0.2.0",
45-
"grunt-dtsm": "0.2.7",
45+
"grunt-dtsm": "0.2.8",
4646
"grunt-exec": "0.4.6",
4747
"grunt-mocha-test": "0.12.7",
48-
"grunt-ts": "3.0.0",
48+
"grunt-ts": "4.0.1",
4949
"grunt-tslint": "2.0.0",
5050
"load-grunt-tasks": "3.1.0",
51-
"power-assert": "0.10.2"
51+
"power-assert": "0.11.0"
5252
}
5353
}

‎test/expected/tsfmt/b/main.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Vector/*
3131
static norm( v: Vector )/*
3232
*/ {
3333
var mag=Vector.mag( v );
34-
var div=( mag===0 )?Infinity:1.0/mag;
34+
var div=( mag===0 )? Infinity:1.0/mag;
3535
return Vector.times( div,v );
3636
}
3737

@@ -72,7 +72,7 @@ class Color/*
7272

7373
static toDrawingColor( c: Color )/*
7474
*/ {
75-
var legalize=d => d>1?1:d;
75+
var legalize=d => d>1? 1:d;
7676
return {
7777
r: Math.floor( legalize( c.r )*255 ),
7878
g: Math.floor( legalize( c.g )*255 ),
@@ -295,7 +295,7 @@ class RayTracer/*
295295
var reflectDir=Vector.minus( d,Vector.times( 2,Vector.times( Vector.dot( normal,d ),normal ) ) );
296296
var naturalColor=Color.plus( Color.background,
297297
this.getNaturalColor( isect.thing,pos,normal,reflectDir,scene ) );
298-
var reflectedColor=( depth>=this.maxDepth )?Color.grey:this.getReflectionColor( isect.thing,pos,normal,reflectDir,scene,depth );
298+
var reflectedColor=( depth>=this.maxDepth )? Color.grey:this.getReflectionColor( isect.thing,pos,normal,reflectDir,scene,depth );
299299
return Color.plus( naturalColor,reflectedColor );
300300
}
301301

@@ -311,17 +311,17 @@ class RayTracer/*
311311
var ldis=Vector.minus( light.pos,pos );
312312
var livec=Vector.norm( ldis );
313313
var neatIsect=this.testRay( { start: pos,dir: livec },scene );
314-
var isInShadow=( neatIsect===undefined )?false:( neatIsect<=Vector.mag( ldis ) );
314+
var isInShadow=( neatIsect===undefined )? false:( neatIsect<=Vector.mag( ldis ) );
315315
if( isInShadow )/*
316316
*/ {
317317
return col;
318318
} else/*
319319
*/ {
320320
var illum=Vector.dot( livec,norm );
321-
var lcolor=( illum>0 )?Color.scale( illum,light.color )
321+
var lcolor=( illum>0 )? Color.scale( illum,light.color )
322322
:Color.defaultColor;
323323
var specular=Vector.dot( livec,Vector.norm( rd ) );
324-
var scolor=( specular>0 )?Color.scale( Math.pow( specular,thing.surface.roughness ),light.color )
324+
var scolor=( specular>0 )? Color.scale( Math.pow( specular,thing.surface.roughness ),light.color )
325325
:Color.defaultColor;
326326
return Color.plus( col,Color.plus( Color.times( thing.surface.diffuse( pos ),lcolor ),
327327
Color.times( thing.surface.specular( pos ),scolor ) ) );

‎tsconfig.json

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
{
2+
"version": "1.5.0-alpha",
3+
"compilerOptions": {
4+
"target": "es5",
5+
"module": "commonjs",
6+
"declaration": false,
7+
"noImplicitAny": false,
8+
"removeComments": true,
9+
"noLib": false
10+
},
11+
"filesGlob": [
12+
"./**/*.ts",
13+
"!./node_modules/**/*.ts",
14+
"./node_modules/typescript/bin/typescript.d.ts",
15+
"!./example/**/*.ts",
16+
"!./test/fixture/**/*.ts",
17+
"!./test/expected/**/*.ts",
18+
"!./*.d.ts"
19+
],
20+
"files": [
21+
"./lib/cli.d.ts",
22+
"./lib/cli.ts",
23+
"./lib/editorconfig.d.ts",
24+
"./lib/formatter.d.ts",
25+
"./lib/formatter.ts",
26+
"./lib/index.d.ts",
27+
"./lib/index.ts",
28+
"./lib/provider/base.d.ts",
29+
"./lib/provider/base.ts",
30+
"./lib/provider/editorconfig.d.ts",
31+
"./lib/provider/editorconfig.ts",
32+
"./lib/provider/tslintjson.d.ts",
33+
"./lib/provider/tslintjson.ts",
34+
"./lib/utils.d.ts",
35+
"./lib/utils.ts",
36+
"./test/indexSpec.d.ts",
37+
"./test/indexSpec.ts",
38+
"./typings/bundle.d.ts",
39+
"./typings/empower/empower.d.ts",
40+
"./typings/es6-promise/es6-promise.d.ts",
41+
"./typings/mocha/mocha.d.ts",
42+
"./typings/node/node.d.ts",
43+
"./typings/power-assert-formatter/power-assert-formatter.d.ts",
44+
"./typings/power-assert/power-assert.d.ts",
45+
"./node_modules/typescript/bin/typescript.d.ts"
46+
]
47+
}

‎typescript-formatter.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Generated by dts-bundle v0.2.0
22
// Dependencies for this module:
3-
// typings/typescript/typescript.d.ts
3+
// node_modules/typescript/bin/typescript.d.ts
44

55
declare module 'typescript-formatter' {
66
import ts = require("typescript");

0 commit comments

Comments
 (0)