Skip to content

Commit

Permalink
feat(tsfmt): pass specified file name to typescript language service.…
Browse files Browse the repository at this point in the history
… support tsx files.
  • Loading branch information
vvakame committed Aug 4, 2015
1 parent e15ae14 commit b9196e9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import utils = require("./utils");

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

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

// Get the formatting edits on the input sources
Expand Down
2 changes: 1 addition & 1 deletion lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export function processString(fileName: string, content: string, opts: Options):
return Promise
.all(optGenPromises)
.then(() => {
var formattedCode = formatter(content, options);
var formattedCode = formatter(fileName, content, options);
if ((<any>formattedCode).trimRight) {
formattedCode = (<any>formattedCode).trimRight();
formattedCode += "\n";
Expand Down

0 comments on commit b9196e9

Please sign in to comment.