mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 23:34:47 -05:00
fix: ts type imports (#5733)
This commit is contained in:
parent
4b06e35765
commit
e191c70989
8 changed files with 36 additions and 3 deletions
|
@ -307,6 +307,20 @@ impl Visit for NewDependencyVisitor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn visit_ts_import_type(
|
||||||
|
&mut self,
|
||||||
|
ts_import_type: &swc_ecma_ast::TsImportType,
|
||||||
|
_parent: &dyn Node,
|
||||||
|
) {
|
||||||
|
// TODO(bartlomieju): possibly add separate DependencyKind
|
||||||
|
let src_str = ts_import_type.arg.value.to_string();
|
||||||
|
self.dependencies.push(DependencyDescriptor {
|
||||||
|
specifier: src_str,
|
||||||
|
kind: DependencyKind::Import,
|
||||||
|
span: ts_import_type.arg.span,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
fn visit_call_expr(
|
fn visit_call_expr(
|
||||||
&mut self,
|
&mut self,
|
||||||
call_expr: &swc_ecma_ast::CallExpr,
|
call_expr: &swc_ecma_ast::CallExpr,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
[WILDCARD]error: Uncaught TypeError: Cannot resolve module "[WILDCARD]/bad-module.ts"
|
error: Cannot resolve module "[WILDCARD]/bad-module.ts" from "[WILDCARD]/error_005_missing_dynamic_import.ts"
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
[WILDCARD]error: Uncaught TypeError: relative import path "bad-module.ts" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/error_012_bad_dynamic_import_specifier.ts"
|
error: relative import path "bad-module.ts" not prefixed with / or ./ or ../ Imported from "[WILDCARD]/error_012_bad_dynamic_import_specifier.ts"
|
||||||
|
|
|
@ -1571,6 +1571,13 @@ itest!(type_directives_redirect {
|
||||||
http_server: true,
|
http_server: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
itest!(ts_type_imports {
|
||||||
|
args: "run --reload ts_type_imports.ts",
|
||||||
|
output: "ts_type_imports.ts.out",
|
||||||
|
exit_code: 1,
|
||||||
|
http_server: true,
|
||||||
|
});
|
||||||
|
|
||||||
itest!(types {
|
itest!(types {
|
||||||
args: "types",
|
args: "types",
|
||||||
output: "types.out",
|
output: "types.out",
|
||||||
|
|
5
cli/tests/ts_type_imports.ts
Normal file
5
cli/tests/ts_type_imports.ts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
/* eslint-disable */
|
||||||
|
|
||||||
|
type Foo = import("./ts_type_imports_foo.ts").Foo;
|
||||||
|
|
||||||
|
const foo: Foo = new Map<string, string>();
|
6
cli/tests/ts_type_imports.ts.out
Normal file
6
cli/tests/ts_type_imports.ts.out
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
Compile [WILDCARD]ts_type_imports.ts
|
||||||
|
error: TS2322 [ERROR]: Type 'Map<string, string>' is not assignable to type 'Foo'.
|
||||||
|
Type 'string' is not assignable to type 'number'.
|
||||||
|
const foo: Foo = new Map<string, string>();
|
||||||
|
~~~
|
||||||
|
at [WILDCARD]ts_type_imports.ts:5:7
|
1
cli/tests/ts_type_imports_foo.ts
Normal file
1
cli/tests/ts_type_imports_foo.ts
Normal file
|
@ -0,0 +1 @@
|
||||||
|
export type Foo = Map<string, number>;
|
|
@ -459,7 +459,7 @@ impl TsCompiler {
|
||||||
import_map,
|
import_map,
|
||||||
permissions.clone(),
|
permissions.clone(),
|
||||||
is_dyn_import,
|
is_dyn_import,
|
||||||
false,
|
true,
|
||||||
);
|
);
|
||||||
|
|
||||||
module_graph_loader.add_to_graph(&module_specifier).await?;
|
module_graph_loader.add_to_graph(&module_specifier).await?;
|
||||||
|
|
Loading…
Reference in a new issue