8000 Fix an “Invalid file extension error” · code-tree/atom-typescript@1bf0c98 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1bf0c98

Browse files
committed
Fix an “Invalid file extension error”
The default implementation for the LanguageServiceHost returns falsy when calling getScriptSnapshot with a directory name.
1 parent 4c37a4a commit 1bf0c98

File tree

5 files changed

+23
-5
lines changed

5 files changed

+23
-5
lines changed

dist/main/atom/views/rView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ var RView = (function (_super) {
6262
});
6363
return RView;
6464
}(sp.ScrollView));
65-
exports.RView = RView;
6665
RView.protocol = 'atomtsview:';
66+
exports.RView = RView;

dist/main/atom/views/renameView.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ var RenameView = (function (_super) {
7474
};
7575
return RenameView;
7676
}(view.View));
77-
exports.RenameView = RenameView;
7877
RenameView.content = html;
78+
exports.RenameView = RenameView;
7979
var panel;
8080
function attach() {
8181
exports.panelView = new RenameView({});

dist/main/lang/core/languageServiceHost2.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ var LanguageServiceHost = (function () {
248248
if (script) {
249249
return getScriptSnapShot(script);
250250
}
251-
else if (fs.existsSync(fileName)) {
251+
else if (_this.fileExists(fileName)) {
252252
_this.config.project.files.push(fileName);
253253
_this.addScript(fileName);
254254
return _this.getScriptSnapshot(fileName);
@@ -259,6 +259,15 @@ var LanguageServiceHost = (function () {
259259
return _this.config.projectFileDirectory;
260260
};
261261
this.getDefaultLibFileName = ts.getDefaultLibFileName;
262+
this.fileExists = function (path) {
263+
try {
264+
var stat = fs.statSync(path);
265+
return stat.isFile();
266+
}
267+
catch (error) {
268+
return false;
269+
}
270+
};
262271
if (!config.project.compilerOptions.noLib && !config.project.compilerOptions.lib) {
263272
this.addScript(exports.getDefaultLibFilePath(config.project.compilerOptions));
264273
}

dist/main/utils/fsUtil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line cha 8000 nge
@@ -7,7 +7,7 @@ var path = require("path");
77
function resolve() {
88
var args = [];
99
for (var _i = 0; _i < arguments.length; _i++) {
10-
args[_i - 0] = arguments[_i];
10+
args[_i] = arguments[_i];
1111
}
1212
return consistentPath(path.resolve.apply(path, args));
1313
}

lib/main/lang/core/languageServiceHost2.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ export class LanguageServiceHost implements ts.LanguageServiceHost {
378378
return getScriptSnapShot(script);
379379
}
380380
// This script should be a part of the project if it exists
381-
else if(fs.existsSync(fileName)){
381+
else if(this.fileExists(fileName)){
382382
this.config.project.files.push(fileName);
383383
this.addScript(fileName);
384384
return this.getScriptSnapshot(fileName);
@@ -389,4 +389,13 @@ export class LanguageServiceHost implements ts.LanguageServiceHost {
389389
return this.config.projectFileDirectory;
390390
}
391391
getDefaultLibFileName = ts.getDefaultLibFileName;
392+
393+
fileExists = (path: string) => {
394+
try {
395+
const stat = fs.statSync(path)
396+
return stat.isFile()
397+
} catch (error) {
398+
return false
399+
}
400+
}
392401
}

0 commit comments

Comments
 (0)
0