Skip to content

Commit

Permalink
chore(lsp): revert import map pre-resolution for jsxImportSource (#23619
Browse files Browse the repository at this point in the history
)
  • Loading branch information
nayeemrmn committed May 1, 2024
1 parent 544d248 commit ac9e07b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 25 deletions.
27 changes: 3 additions & 24 deletions cli/lsp/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,35 +1057,13 @@ impl Default for LspTsConfig {
}

impl LspTsConfig {
pub fn new(
config_file: Option<&ConfigFile>,
import_map: Option<&ImportMap>,
) -> Self {
pub fn new(config_file: Option<&ConfigFile>) -> Self {
let mut ts_config = Self::default();
match ts_config.inner.merge_tsconfig_from_config_file(config_file) {
Ok(Some(ignored_options)) => lsp_warn!("{}", ignored_options),
Err(err) => lsp_warn!("{}", err),
_ => {}
}
let mut maybe_map_jsx_import_source = || {
let import_map = import_map?;
let referrer = &config_file?.specifier;
let compiler_options = ts_config.inner.0.as_object_mut()?;
let jsx_import_source = compiler_options
.get("jsxImportSourceTypes")
.and_then(|v| v.as_str())
.or_else(|| {
compiler_options
.get("jsxImportSource")
.and_then(|v| v.as_str())
})?;
let jsx_import_source =
import_map.resolve(jsx_import_source, referrer).ok()?;
compiler_options
.insert("jsxImportSource".to_string(), json!(jsx_import_source));
Some(())
};
maybe_map_jsx_import_source();
ts_config
}
}
Expand Down Expand Up @@ -1268,6 +1246,8 @@ impl ConfigData {
(lint_options, lint_rules)
});

let ts_config = LspTsConfig::new(config_file.as_ref());

let vendor_dir = config_file.as_ref().and_then(|c| c.vendor_dir_path());

// Load lockfile
Expand Down Expand Up @@ -1436,7 +1416,6 @@ impl ConfigData {
}
}
}
let ts_config = LspTsConfig::new(config_file.as_ref(), import_map.as_ref());

ConfigData {
scope: scope.clone(),
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/lsp_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10628,7 +10628,7 @@ export function B() {
);

let diagnostics = client.read_diagnostics();
assert_eq!(diagnostics.all().len(), 0);
assert_eq!(json!(diagnostics.all()), json!([]));

let res = client.write_request(
"textDocument/hover",
Expand Down

0 comments on commit ac9e07b

Please sign in to comment.