Uh oh!
There was an error while loading. Please reload this page.
Factor out repeated code and call one from another - #125
Conversation
| } | ||
| /** @internal */ | ||
| export function getSourceMapDirectory(host: EmitHost, mapOptions: SourceMapOptions, filePath: string, sourceFile: SourceFile | undefined) { |
There was a problem hiding this comment.
I am currently trying to get rid of the emit host as much as possible since that has a lot of functionality that is not available in the DTE. Could we maybe find a way to subset the methods of EmitHost that actually used here? In #124 I manage to get rid of most of the unimplemented parts of emitHost and just keep the core functionality used in source maps:
constemitHost={getCurrentDirectory: ()=>transpileOptions.currentDirectory??".",getCanonicalFileName: createGetCanonicalFileName(!!compilerOptions.useCaseSensitiveFileNames),useCaseSensitiveFileNames: ()=>!!compilerOptions.useCaseSensitiveFileNames,getCompilerOptions: ()=>compilerOptions.compilerOptions,getCommonSourceDirectory: ()=>ensureTrailingDirectorySeparator(transpileOptions.commonSourceDirectory??"."),};Maybe we can do something similar? I seem to remember I used Pick in some place to pick out just the actually used methods. Not sure if Pick is the best option, but maybe another type with just our methods of interest (or if we find an existing one taht does not grow the API surface too much that would also be great)
There was a problem hiding this comment.
How about this? I made EmitHost -> CoreEmitHost
8e86481 to
87e30ccCompare87e30cc to
66783a3Compareh-joo
commented
Nov 30, 2023
Should be merged after #124 is merged in. |
1ea970e to
f9aa1b6Compare66783a3 to
7362d4bCompareb7d3c82 to
211b056Comparea2fab36 to
c45ffafCompareAlso make the functions use the new type CoreEmitHost to take into account of methods that are not available from DTE mode. Signed-off-by: Hana Joo <hanajoo@google.com>
Signed-off-by: Hana Joo <hanajoo@google.com>
This is totally a non-functional change. No code modification, just moving around.