mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 04:51:22 +00:00
fix: handle @deno-types in export {} (#6202)
* fix: handle @deno-types in export {} * lint * fix tests * fmt * fix test
This commit is contained in:
parent
af69f25319
commit
db70b77e4b
@ -154,7 +154,11 @@ impl SourceFileFetcher {
|
||||
permissions: Permissions,
|
||||
) -> Result<SourceFile, ErrBox> {
|
||||
let module_url = specifier.as_url().to_owned();
|
||||
debug!("fetch_source_file specifier: {} ", &module_url);
|
||||
debug!(
|
||||
"fetch_source_file specifier: {} maybe_referrer: {:#?}",
|
||||
&module_url,
|
||||
maybe_referrer.as_ref()
|
||||
);
|
||||
|
||||
// Check if this file was already fetched and can be retrieved from in-process cache.
|
||||
let maybe_cached_file = self.source_file_cache.get(specifier.to_string());
|
||||
|
@ -504,19 +504,11 @@ pub fn analyze_dependencies_and_references(
|
||||
})
|
||||
.map(|desc| {
|
||||
let location = parser.get_span_location(desc.span);
|
||||
if desc.kind == DependencyKind::Import {
|
||||
let deno_types = get_deno_types(&parser, desc.span);
|
||||
ImportDescriptor {
|
||||
specifier: desc.specifier.to_string(),
|
||||
deno_types,
|
||||
location: location.into(),
|
||||
}
|
||||
} else {
|
||||
ImportDescriptor {
|
||||
specifier: desc.specifier.to_string(),
|
||||
deno_types: None,
|
||||
location: location.into(),
|
||||
}
|
||||
let deno_types = get_deno_types(&parser, desc.span);
|
||||
ImportDescriptor {
|
||||
specifier: desc.specifier.to_string(),
|
||||
deno_types,
|
||||
location: location.into(),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
2
cli/tests/export_type_def.ts
Normal file
2
cli/tests/export_type_def.ts
Normal file
@ -0,0 +1,2 @@
|
||||
// @deno-types="./type_definitions/foo.d.ts"
|
||||
export { foo } from "./type_definitions/foo.js";
|
@ -1729,6 +1729,12 @@ itest!(type_definitions {
|
||||
output: "type_definitions.ts.out",
|
||||
});
|
||||
|
||||
itest!(type_definitions_for_export {
|
||||
args: "run --reload type_definitions_for_export.ts",
|
||||
output: "type_definitions_for_export.ts.out",
|
||||
exit_code: 1,
|
||||
});
|
||||
|
||||
itest!(type_directives_01 {
|
||||
args: "run --reload -L debug type_directives_01.ts",
|
||||
output: "type_directives_01.ts.out",
|
||||
|
7
cli/tests/type_definitions_for_export.ts
Normal file
7
cli/tests/type_definitions_for_export.ts
Normal file
@ -0,0 +1,7 @@
|
||||
import { foo } from "./export_type_def.ts";
|
||||
|
||||
function bar(a: number): void {
|
||||
console.log(a);
|
||||
}
|
||||
|
||||
bar(foo);
|
5
cli/tests/type_definitions_for_export.ts.out
Normal file
5
cli/tests/type_definitions_for_export.ts.out
Normal file
@ -0,0 +1,5 @@
|
||||
Compile [WILDCARD]type_definitions_for_export.ts
|
||||
error: TS2345 [ERROR]: Argument of type 'string' is not assignable to parameter of type 'number'.
|
||||
bar(foo);
|
||||
~~~
|
||||
at [WILDCARD]type_definitions_for_export.ts:7:5
|
@ -1,3 +1,3 @@
|
||||
[WILDCARD]
|
||||
fetch_source_file specifier: file:[WILDCARD]cli/tests/subdir/type_reference.d.ts
|
||||
fetch_source_file specifier: file:[WILDCARD]cli/tests/subdir/type_reference.d.ts [WILDCARD]
|
||||
[WILDCARD]
|
Loading…
Reference in New Issue
Block a user