From 64e70d82e45f9d47c2634f3296d3a1e42514be1c Mon Sep 17 00:00:00 2001 From: Eugene Zolenko Date: Tue, 26 Sep 2017 18:34:25 -0600 Subject: [PATCH] - fix for #32 - fix for typescript typing changes --- dist/host.d.ts | 2 +- dist/rollup-plugin-typescript2.cjs.js | 12 +++++++----- dist/rollup-plugin-typescript2.es.js | 12 +++++++----- src/host.ts | 4 ++-- src/index.ts | 3 +++ src/parse-ts-config.ts | 2 +- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/dist/host.d.ts b/dist/host.d.ts index f296514..2e12b27 100644 --- a/dist/host.d.ts +++ b/dist/host.d.ts @@ -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; diff --git a/dist/rollup-plugin-typescript2.cjs.js b/dist/rollup-plugin-typescript2.cjs.js index 4b76ae2..594c37f 100644 --- a/dist/rollup-plugin-typescript2.cjs.js +++ b/dist/rollup-plugin-typescript2.cjs.js @@ -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; @@ -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; @@ -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(); @@ -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 @@ -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; @@ -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); }); diff --git a/dist/rollup-plugin-typescript2.es.js b/dist/rollup-plugin-typescript2.es.js index 6fd0d44..12758c9 100644 --- a/dist/rollup-plugin-typescript2.es.js +++ b/dist/rollup-plugin-typescript2.es.js @@ -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; @@ -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; @@ -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(); @@ -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 @@ -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; @@ -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); }); diff --git a/src/host.ts b/src/host.ts index 609d31c..11d18fa 100644 --- a/src/host.ts +++ b/src/host.ts @@ -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]; } @@ -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); } diff --git a/src/index.ts b/src/index.ts index 66bd467..bac1bb8 100644 --- a/src/index.ts +++ b/src/index.ts @@ -225,6 +225,9 @@ export default function typescript(options?: Partial) cache().walkTree((id) => { + if (!filter(id)) + return; + const diagnostics = _.concat( convertDiagnostic("syntax", service.getSyntacticDiagnostics(id)), convertDiagnostic("semantic", service.getSemanticDiagnostics(id)), diff --git a/src/parse-ts-config.ts b/src/parse-ts-config.ts index 96cdf7f..effdf02 100644 --- a/src/parse-ts-config.ts +++ b/src/parse-ts-config.ts @@ -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) {