Conversation
|
I think it would be better to make interface EmitHost {
readFile(path: string): string | undefined;
writeFile: ts.WriteFileCallback;
}The signature of Also, |
@ark120202 good call, I changed that. Any idea how to further organize this? I'm not really happy with the multiple definitions of the same default emit host. |
|
@Perryvw if host it a subset of |
src/index.ts
Outdated
| const emitHost = { readFile: ts.sys.readFile }; | ||
| const { transpiledFiles, diagnostics: transpileDiagnostics } = transpile({ program }); | ||
| const emitResult = emitTranspiledFiles(program.getCompilerOptions(), transpiledFiles); | ||
| const emitResult = emitTranspiledFiles(program.getCompilerOptions(), transpiledFiles, emitHost); |
There was a problem hiding this comment.
Since emitTranspiledFiles has a default host it shouldn't be required there
src/Transpile.ts
Outdated
| } | ||
|
|
||
| export interface EmitHost { | ||
| readFile: (path: string, encoding?: string | undefined) => string | undefined; |
There was a problem hiding this comment.
If we never specify encoding we can just drop this argument to simplify custom implementations (ts does that with few hosts). Also, it could be a bit more consistent with method syntax:
| readFile: (path: string, encoding?: string | undefined) => string | undefined; | |
| readFile(path: string): string | undefined; |
No description provided.