Hi I'm using the clearscript V8 engine and want to enable TypeScript.
Following this post I'm able to load the https://rawgit.com/Microsoft/TypeScript/master/lib/typescriptServices.js javascript code into V8 and use that to transpile typescript code, but is seems to use an old version ES3 as a default target for the transpiled js.
How can I set the transpilation target to ES2021? All guidance is about tsconfig used with tsc.exe but I can't seem to figure out how to do this when using typescript.js straight in V8.
CodePudding user response:
The transpile
function actually looks like this:
function transpile(input, compilerOptions, fileName, diagnostics, moduleName) { ... }
My guess is that compilerOptions
is expected to be a JavaScript object that complies with the TSConfig compilerOptions
reference.
UPDATE: Try something like ts.transpile(code, { target: 'es2021' })
.