0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-10-29 08:58:01 -04:00

fix(lsp): do not populate maybe_type slot with import type dep (#11477)

Fixes: #11458
Fixes: #11461
Closes: denoland/vscode_deno#414
This commit is contained in:
Kitson Kelly 2021-07-22 15:00:45 +10:00 committed by GitHub
parent 31afd349d2
commit bdc53b45b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
}
}
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]