From 35216ae5ff583cc395e70779f57a6dd871e7032a Mon Sep 17 00:00:00 2001 From: zhangrengao Date: Tue, 6 Sep 2022 11:04:13 +0800 Subject: [PATCH] Delete tmp output file path, not emit js file Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/I5PW3B?from=project-issue Test: test262, ts2abc ut, ts2abc type test Signed-off-by: zhangrengao Change-Id: I0b23c82973b0f8eb3587c22d8bf5eb827adb246b --- ts2panda/src/cmdOptions.ts | 8 ++++++++ ts2panda/src/index.ts | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ts2panda/src/cmdOptions.ts b/ts2panda/src/cmdOptions.ts index da02f18c62a..bf19d72cd51 100644 --- a/ts2panda/src/cmdOptions.ts +++ b/ts2panda/src/cmdOptions.ts @@ -50,6 +50,7 @@ const ts2pandaOptions = [ { name: 'function-sourcecode', type: Boolean, defaultValue: false, description: "Record functions' sourceCode to support the feature of [function].toString()" }, { name: 'expression-watch-toolchain', type: String, defaultValue: "es2panda", description: "Specify the tool chain used to transform the expression" }, { name: 'source-file', type: String, defaultValue: "", description: "specify the file path info recorded in generated abc" }, + { name: 'generate-tmp-file', type: Boolean, defaultValue: false, description: "whether to generate intermediate temporary files"}, ] @@ -307,6 +308,13 @@ export class CmdOptions { return this.options["source-file"]; } + static needGenerateTmpFile(): boolean { + if (!this.options) { + return false; + } + return this.options["generate-tmp-file"]; + } + // @ts-ignore static parseUserCmd(args: string[]): ts.ParsedCommandLine | undefined { this.options = commandLineArgs(ts2pandaOptions, { partial: true }); diff --git a/ts2panda/src/index.ts b/ts2panda/src/index.ts index c7f898b5823..e243c78b0d2 100644 --- a/ts2panda/src/index.ts +++ b/ts2panda/src/index.ts @@ -52,7 +52,11 @@ function generateDTs(node: ts.SourceFile, options: ts.CompilerOptions) { } function main(fileNames: string[], options: ts.CompilerOptions) { - let program = ts.createProgram(fileNames, options); + const host = ts.createCompilerHost(options); + if (!CmdOptions.needGenerateTmpFile()) { + host.writeFile = () => {}; + } + let program = ts.createProgram(fileNames, options, host); let typeChecker = TypeChecker.getInstance(); typeChecker.setTypeChecker(program.getTypeChecker()); -- Gitee