summaryrefslogtreecommitdiff
path: root/cli/lsp/analysis.rs
diff options
context:
space:
mode:
authorNayeem Rahman <nayeemrmn99@gmail.com>2024-06-12 22:22:57 +0100
committerGitHub <noreply@github.com>2024-06-12 22:22:57 +0100
commitb30e5c09859000896a0caf52e78b0cbdb58955ef (patch)
tree49279398226125675bfecbfe6b180bd731a06ee0 /cli/lsp/analysis.rs
parent1d290ccc2a39d355aa0e43e86f5f4ce09a0bd655 (diff)
fix(lsp): strip .js before probing for valid import fix (#24188)
Diffstat (limited to 'cli/lsp/analysis.rs')
-rw-r--r--cli/lsp/analysis.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/cli/lsp/analysis.rs b/cli/lsp/analysis.rs
index 62feeb602..8480f6e1d 100644
--- a/cli/lsp/analysis.rs
+++ b/cli/lsp/analysis.rs
@@ -76,7 +76,10 @@ static PREFERRED_FIXES: Lazy<HashMap<&'static str, (u32, bool)>> =
static IMPORT_SPECIFIER_RE: Lazy<Regex> =
lazy_regex::lazy_regex!(r#"\sfrom\s+["']([^"']*)["']"#);
-const SUPPORTED_EXTENSIONS: &[&str] = &[".ts", ".tsx", ".js", ".jsx", ".mjs"];
+const SUPPORTED_EXTENSIONS: &[&str] = &[
+ ".ts", ".tsx", ".js", ".jsx", ".mjs", ".mts", ".cjs", ".cts", ".d.ts",
+ ".d.mts", ".d.cts",
+];
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct DataQuickFixChange {
@@ -436,6 +439,7 @@ impl<'a> TsResponseImportMapper<'a> {
return Some(specifier);
}
}
+ let specifier = specifier.strip_suffix(".js").unwrap_or(specifier);
for ext in SUPPORTED_EXTENSIONS {
let specifier_with_ext = format!("{specifier}{ext}");
if self