-
Notifications
You must be signed in to change notification settings - Fork 15
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
Factor out repeated code and call one from another #125
Factor out repeated code and call one from another #125
Conversation
src/compiler/emitter.ts
Outdated
@@ -721,6 +722,62 @@ export function getOutputFileNames(commandLine: ParsedCommandLine, inputFileName | |||
return getOutputs(); | |||
} | |||
|
|||
/** @internal */ | |||
export function getSourceMapDirectory(host: EmitHost, mapOptions: SourceMapOptions, filePath: string, sourceFile: SourceFile | undefined) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
const emitHost = {
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about this? I made EmitHost
-> CoreEmitHost
8e86481
to
87e30cc
Compare
87e30cc
to
66783a3
Compare
Should be merged after #124 is merged in. |
1ea970e
to
f9aa1b6
Compare
66783a3
to
7362d4b
Compare
b7d3c82
to
211b056
Compare
a2fab36
to
c45ffaf
Compare
7362d4b
to
2bc4a1d
Compare
Also 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>
2bc4a1d
to
a97dfbc
Compare
04097f6
into
bloomberg:isolated-declarations
This is totally a non-functional change. No code modification, just moving around.