Skip to content
This repository has been archived by the owner on May 5, 2022. It is now read-only.

Fix for TS 2.4 Module Resolution Changes #63

Merged
merged 3 commits into from
Jul 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions lib/builder.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
'use strict';
var __extends = (this && this.__extends) || function (d, b) {
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
var __extends = (this && this.__extends) || (function () {
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
var fs_1 = require("fs");
var path = require("path");
var crypto = require("crypto");
Expand Down Expand Up @@ -380,6 +386,7 @@ var LanguageServiceHost = (function () {
this.addScriptSnapshot(filename, result);
}
catch (e) {
// ignore
}
}
return result;
Expand Down Expand Up @@ -429,6 +436,12 @@ var LanguageServiceHost = (function () {
LanguageServiceHost.prototype.getCurrentDirectory = function () {
return process.cwd();
};
LanguageServiceHost.prototype.fileExists = function (fileName) {
return !this._noFilesystemLookup && fs_1.existsSync(fileName);
};
LanguageServiceHost.prototype.readFile = function (fileName) {
return this._noFilesystemLookup ? '' : fs_1.readFileSync(fileName, 'utf8');
};
LanguageServiceHost.prototype.getDefaultLibFileName = function (options) {
return normalize(path.join(this.getDefaultLibLocation(), ts.getDefaultLibFileName(options)));
};
Expand Down Expand Up @@ -483,6 +496,6 @@ var LanguageServiceHost = (function () {
}
});
};
LanguageServiceHost._declareModule = /declare\s+module\s+('|")(.+)\1/g;
return LanguageServiceHost;
}());
LanguageServiceHost._declareModule = /declare\s+module\s+('|")(.+)\1/g;
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/// <reference path="../node_modules/typescript/lib/lib.es6.d.ts"/>
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var through = require("through");
var builder = require("./builder");
var ts = require("typescript");
Expand Down
1 change: 1 addition & 0 deletions lib/tests/index.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var index = require("../index");
var assert = require("assert");
describe('options - test that', function () {
Expand Down
1 change: 1 addition & 0 deletions lib/tests/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var utils = require("../utils");
var assert = require("assert");
describe('graph - test that', function () {
Expand Down
1 change: 1 addition & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var collections;
(function (collections) {
var hasOwnProperty = Object.prototype.hasOwnProperty;
Expand Down
10 changes: 9 additions & 1 deletion src/builder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

import {Stats, statSync, readFileSync} from 'fs';
import {Stats, statSync, readFileSync, existsSync} from 'fs';
import * as path from 'path';
import * as crypto from 'crypto';
import * as utils from './utils';
Expand Down Expand Up @@ -554,6 +554,14 @@ class LanguageServiceHost implements ts.LanguageServiceHost {
return process.cwd();
}

fileExists(fileName: string): boolean {
return !this._noFilesystemLookup && existsSync(fileName);
}

readFile(fileName: string): string {
return this._noFilesystemLookup ? '' : readFileSync(fileName, 'utf8');
}

getDefaultLibFileName(options: ts.CompilerOptions): string {
return normalize(path.join(this.getDefaultLibLocation(), ts.getDefaultLibFileName(options)));
}
Expand Down