1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-22 15:24:46 -05: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:
Bartek Iwańczuk 2020-06-10 14:19:41 +02:00 committed by GitHub
parent af69f25319
commit db70b77e4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 15 deletions

View file

@ -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());

View file

@ -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();

View file

@ -0,0 +1,2 @@
// @deno-types="./type_definitions/foo.d.ts"
export { foo } from "./type_definitions/foo.js";

View file

@ -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",

View file

@ -0,0 +1,7 @@
import { foo } from "./export_type_def.ts";
function bar(a: number): void {
console.log(a);
}
bar(foo);

View 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

View file

@ -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]