diff options
author | Bartek Iwańczuk <biwanczuk@gmail.com> | 2024-01-24 14:16:23 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-24 18:46:23 +0530 |
commit | b66f5ed00e83927a976ffdbe45c2ace9641de086 (patch) | |
tree | 60442b72d7f91659715d578c7d4d59c78c8537a9 /cli/args | |
parent | aac0ad32bd589394316223f75e6f511331ff124c (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/args')
-rw-r--r-- | cli/args/mod.rs | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 34448e633..13ee9eeef 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -158,10 +158,8 @@ pub fn ts_config_to_emit_options( _ => (false, false, false, false), }; 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: options.experimental_decorators, + use_decorators_proposal: !options.experimental_decorators, emit_metadata: options.emit_decorator_metadata, imports_not_used_as_values, inline_source_map: options.inline_source_map, @@ -1088,10 +1086,26 @@ impl CliOptions { &self, config_type: TsConfigType, ) -> Result<TsConfigForEmit, AnyError> { - deno_config::get_ts_config_for_emit( + let result = deno_config::get_ts_config_for_emit( config_type, self.maybe_config_file.as_ref(), - ) + ); + + match result { + Ok(mut ts_config_for_emit) => { + if matches!(self.flags.subcommand, DenoSubcommand::Bundle(..)) { + // For backwards compatibility, force `experimentalDecorators` setting + // to true. + *ts_config_for_emit + .ts_config + .0 + .get_mut("experimentalDecorators") + .unwrap() = serde_json::Value::Bool(true); + } + Ok(ts_config_for_emit) + } + Err(err) => Err(err), + } } pub fn resolve_inspector_server(&self) -> Option<InspectorServer> { |