refactor: Cleanup options object parameters (#4296)

This commit is contained in:
Nayeem Rahman 2020-03-10 16:08:58 +00:00 committed by GitHub
parent fbc4731256
commit 6443e4aed1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 110 additions and 164 deletions

View file

@ -302,12 +302,12 @@ export interface TranspileOnlyResult {
*/
export async function transpileOnly(
sources: Record<string, string>,
options?: CompilerOptions
options: CompilerOptions = {}
): Promise<Record<string, TranspileOnlyResult>> {
util.log("Deno.transpileOnly", { sources: Object.keys(sources), options });
const payload = {
sources,
options: options ? JSON.stringify(options) : undefined
options: JSON.stringify(options)
};
const result = await runtimeCompilerOps.transpile(payload);
return JSON.parse(result);
@ -343,12 +343,12 @@ export async function transpileOnly(
export async function compile(
rootName: string,
sources?: Record<string, string>,
options?: CompilerOptions
options: CompilerOptions = {}
): Promise<[DiagnosticItem[] | undefined, Record<string, string>]> {
const payload = {
rootName: sources ? rootName : checkRelative(rootName),
sources,
options: options ? JSON.stringify(options) : undefined,
options: JSON.stringify(options),
bundle: false
};
util.log("Deno.compile", {
@ -391,12 +391,12 @@ export async function compile(
export async function bundle(
rootName: string,
sources?: Record<string, string>,
options?: CompilerOptions
options: CompilerOptions = {}
): Promise<[DiagnosticItem[] | undefined, string]> {
const payload = {
rootName: sources ? rootName : checkRelative(rootName),
sources,
options: options ? JSON.stringify(options) : undefined,
options: JSON.stringify(options),
bundle: true
};
util.log("Deno.bundle", {