Closes #945. Update TypeScript Formatter beautifier
This commit is contained in:
parent
ef8ca9798b
commit
513ebd807c
|
@ -2,7 +2,7 @@ module XYZ {
|
||||||
interface I {
|
interface I {
|
||||||
x: number,
|
x: number,
|
||||||
y,
|
y,
|
||||||
z
|
z
|
||||||
}
|
}
|
||||||
|
|
||||||
var zZz = {
|
var zZz = {
|
||||||
|
@ -31,9 +31,9 @@ if (x === 3) {
|
||||||
}
|
}
|
||||||
console.log("x");
|
console.log("x");
|
||||||
x = y.hey
|
x = y.hey
|
||||||
.b
|
.b
|
||||||
.c
|
.c
|
||||||
.d;
|
.d;
|
||||||
|
|
||||||
|
|
||||||
export class X {
|
export class X {
|
||||||
|
|
|
@ -118,7 +118,8 @@
|
||||||
"strip-json-comments": "^1.0.2",
|
"strip-json-comments": "^1.0.2",
|
||||||
"temp": "^0.8.3",
|
"temp": "^0.8.3",
|
||||||
"tidy-markdown": "^2.0.1",
|
"tidy-markdown": "^2.0.1",
|
||||||
"typescript-formatter": "~0.3.2",
|
"typescript": "^1.8.10",
|
||||||
|
"typescript-formatter": "^2.1.0",
|
||||||
"underscore-plus": "^1.6.6",
|
"underscore-plus": "^1.6.6",
|
||||||
"which": "^1.1.1",
|
"which": "^1.1.1",
|
||||||
"winston": "^1.0.0",
|
"winston": "^1.0.0",
|
||||||
|
|
|
@ -10,17 +10,18 @@ module.exports = class TypeScriptFormatter extends Beautifier
|
||||||
beautify: (text, language, options) ->
|
beautify: (text, language, options) ->
|
||||||
return new @Promise((resolve, reject) =>
|
return new @Promise((resolve, reject) =>
|
||||||
|
|
||||||
format = require("typescript-formatter/lib/formatter")
|
|
||||||
formatterUtils = require("typescript-formatter/lib/utils")
|
|
||||||
|
|
||||||
opts = formatterUtils.createDefaultFormatCodeOptions()
|
|
||||||
opts.TabSize = options.tab_width or options.indent_size
|
|
||||||
opts.IndentSize = options.indent_size
|
|
||||||
opts.IndentStyle = 'space'
|
|
||||||
opts.convertTabsToSpaces = true
|
|
||||||
@verbose('typescript', text, opts)
|
|
||||||
try
|
try
|
||||||
result = format(text, opts)
|
format = require("typescript-formatter/lib/formatter").default
|
||||||
|
formatterUtils = require("typescript-formatter/lib/utils")
|
||||||
|
# @verbose('format', format, formatterUtils)
|
||||||
|
|
||||||
|
opts = formatterUtils.createDefaultFormatCodeOptions()
|
||||||
|
opts.TabSize = options.tab_width or options.indent_size
|
||||||
|
opts.IndentSize = options.indent_size
|
||||||
|
opts.IndentStyle = 'space'
|
||||||
|
opts.convertTabsToSpaces = true
|
||||||
|
@verbose('typescript', text, opts)
|
||||||
|
result = format('', text, opts)
|
||||||
@verbose(result)
|
@verbose(result)
|
||||||
resolve result
|
resolve result
|
||||||
catch e
|
catch e
|
||||||
|
|
Loading…
Reference in New Issue