summaryrefslogtreecommitdiff
path: root/cli/tools/repl/session.rs
diff options
context:
space:
mode:
authorBartek Iwańczuk <biwanczuk@gmail.com>2024-01-24 14:16:23 +0100
committerGitHub <noreply@github.com>2024-01-24 18:46:23 +0530
commitb66f5ed00e83927a976ffdbe45c2ace9641de086 (patch)
tree60442b72d7f91659715d578c7d4d59c78c8537a9 /cli/tools/repl/session.rs
parentaac0ad32bd589394316223f75e6f511331ff124c (diff)
feat: TC39 decorator proposal support (#22040)
This commit adds support for [TC39 Decorator Proposal](https://github.com/tc39/proposal-decorators). These decorators are only available in transpiled sources - ie. non-JavaScript files (because of lack of support in V8). This entails that "experimental TypeScript decorators" are not available by default and require to be configured, with a configuration like this: ``` { "compilerOptions": { "experimentalDecorators": true } } ``` Closes https://github.com/denoland/deno/issues/19160 --------- Signed-off-by: Bartek Iwańczuk <biwanczuk@gmail.com> Co-authored-by: crowlkats <crowlkats@toaxl.com> Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'cli/tools/repl/session.rs')
-rw-r--r--cli/tools/repl/session.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/cli/tools/repl/session.rs b/cli/tools/repl/session.rs
index 3da862e7d..e98f4b430 100644
--- a/cli/tools/repl/session.rs
+++ b/cli/tools/repl/session.rs
@@ -184,6 +184,7 @@ pub struct ReplSession {
/// This is only optional because it's temporarily taken when evaluating.
test_event_receiver: Option<tokio::sync::mpsc::UnboundedReceiver<TestEvent>>,
jsx: ReplJsxState,
+ experimental_decorators: bool,
}
impl ReplSession {
@@ -240,6 +241,11 @@ impl ReplSession {
deno_core::resolve_path("./$deno$repl.ts", cli_options.initial_cwd())
.unwrap();
+ let ts_config_for_emit = cli_options
+ .resolve_ts_config_for_emit(deno_config::TsConfigType::Emit)?;
+ let emit_options =
+ crate::args::ts_config_to_emit_options(ts_config_for_emit.ts_config);
+ let experimental_decorators = emit_options.use_ts_decorators;
let mut repl_session = ReplSession {
npm_resolver,
resolver,
@@ -260,6 +266,7 @@ impl ReplSession {
frag_factory: "React.Fragment".to_string(),
import_source: None,
},
+ experimental_decorators,
};
// inject prelude
@@ -596,10 +603,8 @@ impl ReplSession {
let transpiled_src = parsed_source
.transpile(&deno_ast::EmitOptions {
- // TODO(bartlomieju): change it to default to `false` and only enable
- // if tsconfig.json enabled experimental decorators
- use_ts_decorators: true,
- use_decorators_proposal: false,
+ use_ts_decorators: self.experimental_decorators,
+ use_decorators_proposal: !self.experimental_decorators,
emit_metadata: false,
source_map: false,
inline_source_map: false,