diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-09-04 17:39:30 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-04 17:39:30 +0200 |
commit | 07ad47da53d1fbabf6fc5d26c89dc6ba683d27fd (patch) | |
tree | 9b59f66129ec8a9b6bb1737e8733fd2d352c1f98 /cli | |
parent | 5400f1af6cdca6a71de80093c9d49cdde1f34ce5 (diff) |
BREAKING(config): make supported compilerOptions an allow list (#25432)
Deno has been using a deny list, which doesn't make sense because a lot
of these options don't even work.
Closes #25363
Diffstat (limited to 'cli')
-rw-r--r-- | cli/Cargo.toml | 2 | ||||
-rw-r--r-- | cli/args/deno_json.rs | 16 | ||||
-rw-r--r-- | cli/args/mod.rs | 5 | ||||
-rw-r--r-- | cli/factory.rs | 5 | ||||
-rw-r--r-- | cli/lsp/config.rs | 8 | ||||
-rw-r--r-- | cli/lsp/language_server.rs | 5 | ||||
-rw-r--r-- | cli/tools/check.rs | 5 | ||||
-rw-r--r-- | cli/tools/compile.rs | 2 |
8 files changed, 31 insertions, 17 deletions
diff --git a/cli/Cargo.toml b/cli/Cargo.toml index d7d8eeb7c..016488e5c 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -65,7 +65,7 @@ winres.workspace = true [dependencies] deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] } deno_cache_dir = { workspace = true } -deno_config = { version = "=0.32.0", features = ["workspace", "sync"] } +deno_config = { version = "=0.33.1", features = ["workspace", "sync"] } deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] } deno_doc = { version = "0.148.0", features = ["html", "syntect"] } deno_graph = { version = "=0.82.0" } diff --git a/cli/args/deno_json.rs b/cli/args/deno_json.rs index cbc33aa0b..e9ab0189f 100644 --- a/cli/args/deno_json.rs +++ b/cli/args/deno_json.rs @@ -2,6 +2,7 @@ use std::collections::HashSet; +use deno_config::deno_json::TsConfigForEmit; use deno_core::serde_json; use deno_semver::jsr::JsrDepPackageReq; use deno_semver::jsr::JsrPackageReqReference; @@ -105,3 +106,18 @@ fn values_to_set<'a>( } entries } + +pub fn check_warn_tsconfig(ts_config: &TsConfigForEmit) { + if let Some(ignored_options) = &ts_config.maybe_ignored_options { + log::warn!("{}", ignored_options); + } + let serde_json::Value::Object(obj) = &ts_config.ts_config.0 else { + return; + }; + if obj.get("experimentalDecorators") == Some(&serde_json::Value::Bool(true)) { + log::warn!( + "{} experimentalDecorators compiler option is deprecated and may be removed at any time", + deno_runtime::colors::yellow("Warning"), + ); + } +} diff --git a/cli/args/mod.rs b/cli/args/mod.rs index 4927cf7d0..f7623323f 100644 --- a/cli/args/mod.rs +++ b/cli/args/mod.rs @@ -42,6 +42,7 @@ pub use deno_config::deno_json::TsConfigForEmit; pub use deno_config::deno_json::TsConfigType; pub use deno_config::deno_json::TsTypeLib; pub use deno_config::glob::FilePatterns; +pub use deno_json::check_warn_tsconfig; pub use flags::*; pub use lockfile::CliLockfile; pub use package_json::NpmInstallDepsProvider; @@ -1220,7 +1221,7 @@ impl CliOptions { if let Some(flag) = self.flags.node_modules_dir { return Ok(Some(flag)); } - self.workspace().node_modules_dir_mode().map_err(Into::into) + self.workspace().node_modules_dir().map_err(Into::into) } pub fn vendor_dir_path(&self) -> Option<&PathBuf> { @@ -1731,7 +1732,7 @@ fn resolve_node_modules_folder( Some(mode.uses_node_modules_dir()) } else { workspace - .node_modules_dir_mode()? + .node_modules_dir()? .map(|m| m.uses_node_modules_dir()) .or(flags.vendor) .or_else(|| root_folder.deno_json.as_ref().and_then(|c| c.json.vendor)) diff --git a/cli/factory.rs b/cli/factory.rs index 421553058..81212c788 100644 --- a/cli/factory.rs +++ b/cli/factory.rs @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use crate::args::check_warn_tsconfig; use crate::args::get_root_cert_store; use crate::args::CaData; use crate::args::CliOptions; @@ -520,9 +521,7 @@ impl CliFactory { let cli_options = self.cli_options()?; let ts_config_result = cli_options.resolve_ts_config_for_emit(TsConfigType::Emit)?; - if let Some(ignored_options) = ts_config_result.maybe_ignored_options { - warn!("{}", ignored_options); - } + check_warn_tsconfig(&ts_config_result); let (transpile_options, emit_options) = crate::args::ts_config_to_transpile_and_emit_options( ts_config_result.ts_config, diff --git a/cli/lsp/config.rs b/cli/lsp/config.rs index f9262d12e..fcea96aa5 100644 --- a/cli/lsp/config.rs +++ b/cli/lsp/config.rs @@ -1387,10 +1387,8 @@ impl ConfigData { } } - let node_modules_dir = member_dir - .workspace - .node_modules_dir_mode() - .unwrap_or_default(); + let node_modules_dir = + member_dir.workspace.node_modules_dir().unwrap_or_default(); let byonm = match node_modules_dir { Some(mode) => mode == NodeModulesDirMode::Manual, None => member_dir.workspace.root_pkg_json().is_some(), @@ -1873,7 +1871,7 @@ fn resolve_node_modules_dir( // `nodeModulesDir: true` setting in the deno.json file. This is to // reduce the chance of modifying someone's node_modules directory // without them having asked us to do so. - let node_modules_mode = workspace.node_modules_dir_mode().ok().flatten(); + let node_modules_mode = workspace.node_modules_dir().ok().flatten(); let explicitly_disabled = node_modules_mode == Some(NodeModulesDirMode::None); if explicitly_disabled { return None; diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 05c54dfc6..2bb13e5e4 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -966,9 +966,8 @@ impl Inner { .await; for config_file in self.config.tree.config_files() { (|| { - let compiler_options = config_file.to_compiler_options().ok()?.0; - let compiler_options_obj = compiler_options.as_object()?; - let jsx_import_source = compiler_options_obj.get("jsxImportSource")?; + let compiler_options = config_file.to_compiler_options().ok()?.options; + let jsx_import_source = compiler_options.get("jsxImportSource")?; let jsx_import_source = jsx_import_source.as_str()?; let referrer = config_file.specifier.clone(); let specifier = Url::parse(&format!( diff --git a/cli/tools/check.rs b/cli/tools/check.rs index a2bfb9d9b..9232f324b 100644 --- a/cli/tools/check.rs +++ b/cli/tools/check.rs @@ -14,6 +14,7 @@ use deno_terminal::colors; use once_cell::sync::Lazy; use regex::Regex; +use crate::args::check_warn_tsconfig; use crate::args::CliOptions; use crate::args::TsConfig; use crate::args::TsConfigType; @@ -118,9 +119,7 @@ impl TypeChecker { .cli_options .resolve_ts_config_for_emit(TsConfigType::Check { lib: options.lib })?; if options.log_ignored_options { - if let Some(ignored_options) = ts_config_result.maybe_ignored_options { - log::warn!("{}", ignored_options); - } + check_warn_tsconfig(&ts_config_result); } let type_check_mode = options.type_check_mode; diff --git a/cli/tools/compile.rs b/cli/tools/compile.rs index 90ee0e270..b9620cfde 100644 --- a/cli/tools/compile.rs +++ b/cli/tools/compile.rs @@ -1,5 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use crate::args::check_warn_tsconfig; use crate::args::CompileFlags; use crate::args::Flags; use crate::factory::CliFactory; @@ -79,6 +80,7 @@ pub async fn compile( let ts_config_for_emit = cli_options .resolve_ts_config_for_emit(deno_config::deno_json::TsConfigType::Emit)?; + check_warn_tsconfig(&ts_config_for_emit); let (transpile_options, emit_options) = crate::args::ts_config_to_transpile_and_emit_options( ts_config_for_emit.ts_config, |