Skip to content

Commit

Permalink
- fix for #32
Browse files Browse the repository at this point in the history
- fix for typescript typing changes
  • Loading branch information
ezolenko committed Sep 27, 2017
1 parent 2fe9435 commit 64e70d8
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion dist/host.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export declare class LanguageServiceHost implements tsTypes.LanguageServiceHost
getDefaultLibFileName(opts: tsTypes.CompilerOptions): string;
useCaseSensitiveFileNames(): boolean;
readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[];
readFile(path: string, encoding?: string): string;
readFile(path: string, encoding?: string): string | undefined;
fileExists(path: string): boolean;
getTypeRootsVersion(): number;
directoryExists(directoryName: string): boolean;
Expand Down
12 changes: 7 additions & 5 deletions dist/rollup-plugin-typescript2.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var VerbosityLevel;
VerbosityLevel[VerbosityLevel["Info"] = 2] = "Info";
VerbosityLevel[VerbosityLevel["Debug"] = 3] = "Debug";
})(VerbosityLevel || (VerbosityLevel = {}));
var ConsoleContext = (function () {
var ConsoleContext = /** @class */ (function () {
function ConsoleContext(verbosity, prefix) {
if (prefix === void 0) { prefix = ""; }
this.verbosity = verbosity;
Expand Down Expand Up @@ -72,7 +72,7 @@ var ConsoleContext = (function () {
return ConsoleContext;
}());

var RollupContext = (function () {
var RollupContext = /** @class */ (function () {
function RollupContext(verbosity, bail, context, prefix) {
if (prefix === void 0) { prefix = ""; }
this.verbosity = verbosity;
Expand Down Expand Up @@ -124,7 +124,7 @@ function normalize(fileName) {
return fileName.split("\\").join("/");
}

var LanguageServiceHost = (function () {
var LanguageServiceHost = /** @class */ (function () {
function LanguageServiceHost(parsedConfig) {
this.parsedConfig = parsedConfig;
this.cwd = process.cwd();
Expand Down Expand Up @@ -197,7 +197,7 @@ var LanguageServiceHost = (function () {
* Saves data in new cache folder or reads it from old one.
* Avoids perpetually growing cache and situations when things need to consider changed and then reverted data to be changed.
*/
var RollingCache = (function () {
var RollingCache = /** @class */ (function () {
/**
* @param cacheRoot: root folder for the cache
* @param checkNewCache: whether to also look in new cache when reading from cache
Expand Down Expand Up @@ -281,7 +281,7 @@ function convertDiagnostic(type, data) {
return entry;
});
}
var TsCache = (function () {
var TsCache = /** @class */ (function () {
function TsCache(host, cache, options, rollupConfig, rootFilenames, context) {
var _this = this;
this.host = host;
Expand Down Expand Up @@ -626,6 +626,8 @@ function typescript(options) {
if (watchMode && round === 0) {
context.debug("running in watch mode");
cache().walkTree(function (id) {
if (!filter$$1(id))
return;
var diagnostics = _.concat(convertDiagnostic("syntax", service.getSyntacticDiagnostics(id)), convertDiagnostic("semantic", service.getSemanticDiagnostics(id)));
printDiagnostics(context, diagnostics);
});
Expand Down
12 changes: 7 additions & 5 deletions dist/rollup-plugin-typescript2.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var VerbosityLevel;
VerbosityLevel[VerbosityLevel["Info"] = 2] = "Info";
VerbosityLevel[VerbosityLevel["Debug"] = 3] = "Debug";
})(VerbosityLevel || (VerbosityLevel = {}));
var ConsoleContext = (function () {
var ConsoleContext = /** @class */ (function () {
function ConsoleContext(verbosity, prefix) {
if (prefix === void 0) { prefix = ""; }
this.verbosity = verbosity;
Expand Down Expand Up @@ -70,7 +70,7 @@ var ConsoleContext = (function () {
return ConsoleContext;
}());

var RollupContext = (function () {
var RollupContext = /** @class */ (function () {
function RollupContext(verbosity, bail, context, prefix) {
if (prefix === void 0) { prefix = ""; }
this.verbosity = verbosity;
Expand Down Expand Up @@ -122,7 +122,7 @@ function normalize(fileName) {
return fileName.split("\\").join("/");
}

var LanguageServiceHost = (function () {
var LanguageServiceHost = /** @class */ (function () {
function LanguageServiceHost(parsedConfig) {
this.parsedConfig = parsedConfig;
this.cwd = process.cwd();
Expand Down Expand Up @@ -195,7 +195,7 @@ var LanguageServiceHost = (function () {
* Saves data in new cache folder or reads it from old one.
* Avoids perpetually growing cache and situations when things need to consider changed and then reverted data to be changed.
*/
var RollingCache = (function () {
var RollingCache = /** @class */ (function () {
/**
* @param cacheRoot: root folder for the cache
* @param checkNewCache: whether to also look in new cache when reading from cache
Expand Down Expand Up @@ -279,7 +279,7 @@ function convertDiagnostic(type, data) {
return entry;
});
}
var TsCache = (function () {
var TsCache = /** @class */ (function () {
function TsCache(host, cache, options, rollupConfig, rootFilenames, context) {
var _this = this;
this.host = host;
Expand Down Expand Up @@ -624,6 +624,8 @@ function typescript(options) {
if (watchMode && round === 0) {
context.debug("running in watch mode");
cache().walkTree(function (id) {
if (!filter$$1(id))
return;
var diagnostics = concat(convertDiagnostic("syntax", service.getSyntacticDiagnostics(id)), convertDiagnostic("semantic", service.getSemanticDiagnostics(id)));
printDiagnostics(context, diagnostics);
});
Expand Down
4 changes: 2 additions & 2 deletions src/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class LanguageServiceHost implements tsTypes.LanguageServiceHost

if (existsSync(fileName))
{
this.snapshots[fileName] = tsModule.ScriptSnapshot.fromString(tsModule.sys.readFile(fileName));
this.snapshots[fileName] = tsModule.ScriptSnapshot.fromString(tsModule.sys.readFile(fileName)!);
this.versions[fileName] = (this.versions[fileName] || 0) + 1;
return this.snapshots[fileName];
}
Expand Down Expand Up @@ -84,7 +84,7 @@ export class LanguageServiceHost implements tsTypes.LanguageServiceHost
return tsModule.sys.readDirectory(path, extensions, exclude, include);
}

public readFile(path: string, encoding?: string): string
public readFile(path: string, encoding?: string): string | undefined
{
return tsModule.sys.readFile(path, encoding);
}
Expand Down
3 changes: 3 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ export default function typescript(options?: Partial<IOptions>)

cache().walkTree((id) =>
{
if (!filter(id))
return;

const diagnostics = _.concat(
convertDiagnostic("syntax", service.getSyntacticDiagnostics(id)),
convertDiagnostic("semantic", service.getSemanticDiagnostics(id)),
Expand Down
2 changes: 1 addition & 1 deletion src/parse-ts-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function parseTsConfig(tsconfig: string, context: IContext, pluginOptions
throw new Error(`couldn't find '${tsconfig}' in ${process.cwd()}`);

const text = tsModule.sys.readFile(fileName);
const result = tsModule.parseConfigFileTextToJson(fileName, text);
const result = tsModule.parseConfigFileTextToJson(fileName, text!);

if (result.error)
{
Expand Down

0 comments on commit 64e70d8

Please sign in to comment.