diff --git a/ts2panda/src/ignoreSyntaxError.ts b/ts2panda/src/ignoreSyntaxError.ts new file mode 100644 index 0000000000000000000000000000000000000000..de947ee61b9e0777f6736c5c128aaddf7db6c1d0 --- /dev/null +++ b/ts2panda/src/ignoreSyntaxError.ts @@ -0,0 +1,4 @@ +const BigInt_literals_are_not_available_when_targeting_lower_than_ES2020: number = 2737; +export const IGNORE_ERROR_CODE: number[] = [ + BigInt_literals_are_not_available_when_targeting_lower_than_ES2020 +]; \ No newline at end of file diff --git a/ts2panda/src/index.ts b/ts2panda/src/index.ts index 866827b25dd93dc2907a5b0c25728ea2c2624410..e1b34e285c1ffe9fa790adb63fb0443608df4e23 100644 --- a/ts2panda/src/index.ts +++ b/ts2panda/src/index.ts @@ -24,6 +24,7 @@ import { LOGE } from "./log"; import { setGlobalDeclare, setGlobalStrict } from "./strictMode"; import { TypeChecker } from "./typeChecker"; import { setPos, isBase64Str, transformCommonjsModule } from "./base/util"; +import { IGNORE_ERROR_CODE } from './ignoreSyntaxError' function checkIsGlobalDeclaration(sourceFile: ts.SourceFile) { for (let statement of sourceFile.statements) { @@ -65,6 +66,10 @@ function main(fileNames: string[], options: ts.CompilerOptions) { } } + if (checkDiagnosticsError(program)) { + return; + } + let emitResult = program.emit( undefined, undefined, @@ -120,6 +125,10 @@ function main(fileNames: string[], options: ts.CompilerOptions) { .concat(emitResult.diagnostics); allDiagnostics.forEach(diagnostic => { + let ignoerErrorSet = new Set(IGNORE_ERROR_CODE); + if (ignoerErrorSet.has(diagnostic.code)) { + return; + } diag.printDiagnostic(diagnostic); }); } @@ -245,12 +254,29 @@ function keepWatchingFiles(filePath: string, parsed: ts.ParsedCommandLine | unde }); } +function checkDiagnosticsError(program: ts.Program) { + let diagnosticsFlag = false; + let allDiagnostics = ts + .getPreEmitDiagnostics(program); + allDiagnostics.forEach(diagnostic => { + let ignoerErrorSet = new Set(IGNORE_ERROR_CODE); + if (ignoerErrorSet.has(diagnostic.code)) { + diagnosticsFlag = false; + return; + } + diagnosticsFlag = true; + diag.printDiagnostic(diagnostic); + }); + + return diagnosticsFlag; +} + namespace Compiler { export namespace Options { export let Default: ts.CompilerOptions = { outDir: "../tmp/build", allowJs: true, - noEmitOnError: true, + noEmitOnError: false, noImplicitAny: true, target: ts.ScriptTarget.ES2017, module: ts.ModuleKind.ES2015, diff --git a/ts2panda/src/statement/classStatement.ts b/ts2panda/src/statement/classStatement.ts index ed9498afbf8359bcb57673c151c9b11f60caad3e..3b816f6be6646e26925daf2234b63d05ff560079 100644 --- a/ts2panda/src/statement/classStatement.ts +++ b/ts2panda/src/statement/classStatement.ts @@ -416,10 +416,11 @@ function loadCtorObj(node: ts.CallExpression, compiler: Compiler) { return; } - let nearestFuncScope = recorder.getScopeOfNode(nearestFunc); - if (!nearestFuncScope) { - return; - } + // TODO the design needs to be reconsidered + // let nearestFuncScope = recorder.getScopeOfNode(nearestFunc); + // if (!nearestFuncScope) { + // return; + // } if (ts.isConstructorDeclaration(nearestFunc)) { pandaGen.loadAccumulator(node, getVregisterCache(pandaGen, CacheList.FUNC));