mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
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>
This commit is contained in:
parent
aac0ad32bd
commit
b66f5ed00e
16 changed files with 145 additions and 32 deletions
|
@ -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> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue