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

Update/typescript formatter #1766

Merged
merged 8 commits into from
Jul 15, 2017
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
77 changes: 38 additions & 39 deletions examples/simple-jsbeautifyrc/typescript/expected/test2.ts
Original file line number Diff line number Diff line change
@@ -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:
console.log("x");
break;
default:
console.log("y");
}

if (x === 3) {
if (y === 4) {
console.log("hey");
switch (y {
case X:
console.log("x");
break;
default:
console.log("y");
}
console.log("x");
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;
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");
}
}
}
}
89 changes: 44 additions & 45 deletions examples/simple-jsbeautifyrc/typescript/original/test2.ts
Original file line number Diff line number Diff line change
@@ -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");
}

if (x === 3) {
if (y === 4) {
console.log("hey");
}
console.log("x");
console.log("x");
break;
default:
console.log("y");
}

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");
}
}
}
}
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@
{
"name": "Eli Donahue",
"url": "https://github.com/elijdonahue"
},
{
"name": "Kamontat Chantrachirathumrong",
"url": "https://github.com/kamontat"
}
],
"engines": {
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 5 additions & 5 deletions src/beautifiers/typescript-formatter.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down