1
0
Fork 0
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:
Bartek Iwańczuk 2020-05-22 19:05:18 +02:00 committed by GitHub
parent 4b06e35765
commit e191c70989
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 36 additions and 3 deletions

View file

@ -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(
&mut self,
call_expr: &swc_ecma_ast::CallExpr,

View file

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

View file

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

View file

@ -1571,6 +1571,13 @@ itest!(type_directives_redirect {
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 {
args: "types",
output: "types.out",

View file

@ -0,0 +1,5 @@
/* eslint-disable */
type Foo = import("./ts_type_imports_foo.ts").Foo;
const foo: Foo = new Map<string, string>();

View 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

View file

@ -0,0 +1 @@
export type Foo = Map<string, number>;

View file

@ -459,7 +459,7 @@ impl TsCompiler {
import_map,
permissions.clone(),
is_dyn_import,
false,
true,
);
module_graph_loader.add_to_graph(&module_specifier).await?;