fix(lsp): do not populate maybe_type slot with import type dep
Fixes:
Fixes:
Closes: denoland/vscode_deno#414
@@ -393,17 +393,8 @@ pub fn analyze_dependencies(
character: end.col_display as u32,
},
};
- match desc.kind {
- swc_ecmascript::dep_graph::DependencyKind::ExportType
- | swc_ecmascript::dep_graph::DependencyKind::ImportType => {
- dep.maybe_type_specifier_range = Some(range);
- dep.maybe_type = Some(resolved_import)
- }
- _ => {
dep.maybe_code_specifier_range = Some(range);
dep.maybe_code = Some(resolved_import);
- }
- }
if dep.maybe_type.is_none() {
if let Some((resolved_dependency, specifier, loc)) =
maybe_resolved_type_dependency
@@ -1260,8 +1251,11 @@ mod tests {
Status,
} from "https://deno.land/x/oak@v6.3.2/mod.ts";
+ import type { Component } from "https://esm.sh/preact";
+ import { h, Fragment } from "https://esm.sh/preact";
+
// @deno-types="https://deno.land/x/types/react/index.d.ts";
- import * as React from "https://cdn.skypack.dev/react";
+ import React from "https://cdn.skypack.dev/react";
"#;
let parsed_module =
parse_module(&specifier, source, &MediaType::TypeScript).unwrap();
@@ -1272,7 +1266,7 @@ mod tests {
&None,
);
assert!(maybe_type.is_none());
- assert_eq!(actual.len(), 2);
+ assert_eq!(actual.len(), 3);
assert_eq!(
actual.get("https://cdn.skypack.dev/react").cloned(),
Some(Dependency {
@@ -1285,21 +1279,21 @@ mod tests {
)),
maybe_code_specifier_range: Some(Range {
start: Position {
- line: 8,
- character: 27,
+ line: 11,
+ character: 22,
},
end: Position {
- line: 8,
- character: 58,
+ line: 11,
+ character: 53,
}
}),
maybe_type_specifier_range: Some(Range {
start: Position {
- line: 7,
+ line: 10,
character: 20,
},
end: Position {
- line: 7,
+ line: 10,
character: 62,
}
})
@@ -1326,6 +1320,27 @@ mod tests {
maybe_type_specifier_range: None,
})
);
+ assert_eq!(
+ actual.get("https://esm.sh/preact").cloned(),
+ Some(Dependency {
+ is_dynamic: false,
+ maybe_code: Some(ResolvedDependency::Resolved(
+ resolve_url("https://esm.sh/preact").unwrap()
+ )),
+ maybe_type: None,
+ maybe_code_specifier_range: Some(Range {
+ start: Position {
+ line: 8,
+ character: 32
+ },
+ end: Position {
+ line: 8,
+ character: 55
+ }
+ }),
+ maybe_type_specifier_range: None,
+ }),
+ );
}
#[test]
