Merge pull request #1766 from kamontat/update/typescript-formatter

Update/typescript formatter
This commit is contained in:
Glavin Wiechert 2017-07-15 17:20:23 -03:00 committed by GitHub
commit 9a9bec035e
5 changed files with 94 additions and 92 deletions

View File

@ -1,5 +1,5 @@
# Next
- ...
- Fixes #1638. update type-formatter and Fixes indent size not supported
# v0.30.4 (2017-07-14)
- Fixes #1732. Improve deprecation message for old options for new Executables

View File

@ -1,56 +1,55 @@
module XYZ {
interface I {
x: number,
y,
y,
z
}
}
var zZz = {
a: 123,
b: 456
};
var zZz = {
a: 123,
b: 456
};
enum En {
AB,
CD
}
enum En {
AB,
CD
}
var y = 3;
var y = 3;
switch (y {
case X:
switch (y {
case X:
console.log("x");
break;
default:
console.log("y");
}
if (x === 3) {
if (y === 4) {
console.log("hey");
}
console.log("x");
break;
default:
console.log("y");
}
x = y.hey
.b
.c
.d;
if (x === 3) {
if (y === 4) {
console.log("hey");
}
console.log("x");
x = y.hey
.b
.c
.d;
export class X {
private x: number;
constructor() {
console.log("hi");
}
export class X {
private x: number;
constructor() {
console.log("hi");
public mem() {
console.log("yes");
}
}
public mem() {
console.log("yes");
function xyz() {
function mem() {
console.log("yes");
}
}
}
function xyz() {
function mem() {
console.log("yes");
}
}
}

View File

@ -1,56 +1,55 @@
module XYZ {
interface I {
x: number,
y,
z
interface I {
x: number,
y,
z
}
var zZz = {
a: 123,
b: 456
};
enum En {
AB,
CD
}
var zZz={
a: 123,
b: 456
};
var y = 3;
enum En {
AB,
CD
}
var y = 3;
switch(y {
switch (y {
case X:
console.log("x");
break;
default:
console.log("y");
}
console.log("x");
break;
default:
console.log("y");
}
if (x === 3) {
if (y === 4) {
console.log("hey");
}
console.log("x");
if (x === 3) {
if (y === 4) {
console.log("hey");
}
console.log("x");
x = y.hey
.b
.c
.d;
.b
.c
.d;
export class X {
private x: number;
export class X {
private x : number;
constructor() {
console.log("hi");
}
constructor() {
console.log("hi");
}
public mem() {
console.log("yes");
}
}
public mem() {
console.log("yes");
}
function xyz() {
function mem() {
console.log("yes");
}
function xyz() {
function mem() {
console.log("yes");
}
}
}
}
}

View File

@ -142,6 +142,10 @@
{
"name": "Eli Donahue",
"url": "https://github.com/elijdonahue"
},
{
"name": "Kamontat Chantrachirathumrong",
"url": "https://github.com/kamontat"
}
],
"engines": {
@ -185,8 +189,8 @@
"strip-json-comments": "^2.0.1",
"temp": "^0.8.3",
"tidy-markdown": "2.0.3",
"typescript": "1.8.10",
"typescript-formatter": "2.3.0",
"typescript": "2.4.1",
"typescript-formatter": "5.2.0",
"underscore-plus": "^1.6.6",
"universal-analytics": "0.4.13",
"which": "1.2.14",

View File

@ -16,14 +16,14 @@ module.exports = class TypeScriptFormatter extends Beautifier
formatterUtils = require("typescript-formatter/lib/utils")
# @verbose('format', format, formatterUtils)
opts = formatterUtils.createDefaultFormatCodeOptions()
opts = formatterUtils.createDefaultFormatCodeSettings()
if options.indent_with_tabs
opts.ConvertTabsToSpaces = false
opts.convertTabsToSpaces = false
else
opts.TabSize = options.tab_width or options.indent_size
opts.IndentSize = options.indent_size
opts.IndentStyle = 'space'
opts.tabSize = options.tab_width or options.indent_size
opts.indentSize = options.indent_size
opts.indentStyle = 'space'
@verbose('typescript', text, opts)
result = format('', text, opts)