Skip to content

Commit 60c2919

Browse files
committed
refactor(tsfmt): refactor own LanguageServiceHost implementation
1 parent f5a5ff4 commit 60c2919

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/formatter.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as ts from "typescript";
33
import { createDefaultFormatCodeSettings } from "./utils";
44

55
class LanguageServiceHost implements ts.LanguageServiceHost {
6-
files: { [fileName: string]: ts.IScriptSnapshot; } = {};
6+
files: ts.MapLike<ts.IScriptSnapshot> = {};
77
addFile(fileName: string, text: string) {
88
this.files[fileName] = ts.ScriptSnapshot.fromString(text);
99
}
@@ -12,10 +12,10 @@ class LanguageServiceHost implements ts.LanguageServiceHost {
1212

1313
getCompilationSettings = () => ts.getDefaultCompilerOptions();
1414
getScriptFileNames = () => Object.keys(this.files);
15-
getScriptVersion = (_fileName: string) => "1";
15+
getScriptVersion = (_fileName: string) => "0";
1616
getScriptSnapshot = (fileName: string) => this.files[fileName];
1717
getCurrentDirectory = () => process.cwd();
18-
getDefaultLibFileName = (_options: ts.CompilerOptions) => "lib";
18+
getDefaultLibFileName = (options: ts.CompilerOptions) => ts.getDefaultLibFilePath(options);
1919
}
2020

2121
export function format(fileName: string, text: string, options = createDefaultFormatCodeSettings()) {

0 commit comments

Comments
 (0)