Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove use of private API #351

Merged
merged 4 commits into from
Feb 1, 2019
Merged
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
19 changes: 18 additions & 1 deletion packages/jsii/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export class Compiler implements Emitter {
if (files.length > 0) {
ret.push(...files);
} else {
const parseConfigHost = (ts as any /* private API */).parseConfigHostFromCompilerHost(this.compilerHost);
const parseConfigHost = parseConfigHostFromCompilerHost(this.compilerHost);
const parsed = ts.parseJsonConfigFileContent(this.typescriptConfig, parseConfigHost, this.options.projectInfo.projectRoot);
ret.push(...parsed.fileNames);
}
Expand Down Expand Up @@ -323,3 +323,20 @@ function nodeJsCompatibleSearchPaths(dir: string): string[] {

return ret;
}

function parseConfigHostFromCompilerHost(host: ts.CompilerHost): ts.ParseConfigHost {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a link to the original implementation? I mean a permalink to the particular location... If it ever needs to be updated, that'll probably help track down where the new version of it lives...

// Copied from upstream
// https://github.com/Microsoft/TypeScript/blob/9e05abcfd3f8bb3d6775144ede807daceab2e321/src/compiler/program.ts#L3105
return {
fileExists: f => host.fileExists(f),
readDirectory(root, extensions, excludes, includes, depth) {
if (host.readDirectory === undefined) {
throw new Error("'CompilerHost.readDirectory' must be implemented to correctly process 'projectReferences'");
}
return host.readDirectory!(root, extensions, excludes, includes, depth);
},
readFile: f => host.readFile(f),
useCaseSensitiveFileNames: host.useCaseSensitiveFileNames(),
trace: host.trace ? (s) => host.trace!(s) : undefined
};
}