Skip to content

Commit a138e63

Browse files
committed
Avoid using this in object literals where possible
1 parent a3d9a85 commit a138e63

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/compiler/sys.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ namespace ts {
182182
return matchFiles(path, extensions, excludes, includes, /*useCaseSensitiveFileNames*/ false, shell.CurrentDirectory, getAccessibleFileSystemEntries);
183183
}
184184

185-
return {
185+
const wscriptSystem: System = {
186186
args,
187187
newLine: "\r\n",
188188
useCaseSensitiveFileNames: false,
@@ -200,8 +200,8 @@ namespace ts {
200200
directoryExists(path: string) {
201201
return fso.FolderExists(path);
202202
},
203-
createDirectory(this: System, directoryName: string) {
204-
if (!this.directoryExists(directoryName)) {
203+
createDirectory(directoryName: string) {
204+
if (!wscriptSystem.directoryExists(directoryName)) {
205205
fso.CreateFolder(directoryName);
206206
}
207207
},
@@ -221,6 +221,7 @@ namespace ts {
221221
}
222222
}
223223
};
224+
return wscriptSystem;
224225
}
225226

226227
function getNodeSystem(): System {
@@ -439,7 +440,7 @@ namespace ts {
439440
return filter<string>(_fs.readdirSync(path), p => fileSystemEntryExists(combinePaths(path, p), FileSystemEntryKind.Directory));
440441
}
441442

442-
return {
443+
const nodeSystem: System = {
443444
args: process.argv.slice(2),
444445
newLine: _os.EOL,
445446
useCaseSensitiveFileNames: useCaseSensitiveFileNames,
@@ -500,8 +501,8 @@ namespace ts {
500501
},
501502
fileExists,
502503
directoryExists,
503-
createDirectory(this: System, directoryName: string) {
504-
if (!this.directoryExists(directoryName)) {
504+
createDirectory(directoryName: string) {
505+
if (!nodeSystem.directoryExists(directoryName)) {
505506
_fs.mkdirSync(directoryName);
506507
}
507508
},
@@ -549,6 +550,7 @@ namespace ts {
549550
return _fs.realpathSync(path);
550551
}
551552
};
553+
return nodeSystem;
552554
}
553555

554556
function getChakraSystem(): System {

src/server/editorServices.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,9 +2081,9 @@ namespace ts.server {
20812081
const walkFns = {
20822082
goSubtree: true,
20832083
done: false,
2084-
leaf: function (this: ILineIndexWalker, relativeStart: number, relativeLength: number, ll: LineLeaf) {
2084+
leaf: function (relativeStart: number, relativeLength: number, ll: LineLeaf) {
20852085
if (!f(ll, relativeStart, relativeLength)) {
2086-
this.done = true;
2086+
walkFns.done = true;
20872087
}
20882088
}
20892089
};

0 commit comments

Comments
 (0)