summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-07-17 15:50:17 +0200
committerGitHub <noreply@github.com>2020-07-17 15:50:17 +0200
commit6e34f6a7cca11ba245f0b55c3b956b59948b37b7 (patch)
tree6263c56dc09c24d2bfa57505223e6932c7cf9fa7 /cli/tests
parent121eaa4efcaa5c8a4cab25eed15de07642e0407d (diff)
fix: providing empty source code for missing compiled files (#6760)
This commit adds a fallback mechanism for absent compiled source file. Because imported type declaration files are not emitted by TS compiler and their imports are not elided users often hit "No such file or directory" error. With this commit in such situation an empty source file will be provided to V8 with a warning to the user suggesting using "import type"/ "export type" syntax instead.
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration_tests.rs5
-rw-r--r--cli/tests/ts_type_only_import.d.ts3
-rw-r--r--cli/tests/ts_type_only_import.ts1
-rw-r--r--cli/tests/ts_type_only_import.ts.out4
4 files changed, 13 insertions, 0 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs
index f832358ff..baed26523 100644
--- a/cli/tests/integration_tests.rs
+++ b/cli/tests/integration_tests.rs
@@ -1972,6 +1972,11 @@ itest!(ts_decorators {
output: "ts_decorators.ts.out",
});
+itest!(ts_type_only_import {
+ args: "run --reload ts_type_only_import.ts",
+ output: "ts_type_only_import.ts.out",
+});
+
itest!(swc_syntax_error {
args: "run --reload swc_syntax_error.ts",
output: "swc_syntax_error.ts.out",
diff --git a/cli/tests/ts_type_only_import.d.ts b/cli/tests/ts_type_only_import.d.ts
new file mode 100644
index 000000000..d48e4b48a
--- /dev/null
+++ b/cli/tests/ts_type_only_import.d.ts
@@ -0,0 +1,3 @@
+export interface HelloWorld {
+ a: string;
+}
diff --git a/cli/tests/ts_type_only_import.ts b/cli/tests/ts_type_only_import.ts
new file mode 100644
index 000000000..53e114373
--- /dev/null
+++ b/cli/tests/ts_type_only_import.ts
@@ -0,0 +1 @@
+export * from "./ts_type_only_import.d.ts";
diff --git a/cli/tests/ts_type_only_import.ts.out b/cli/tests/ts_type_only_import.ts.out
new file mode 100644
index 000000000..d7120966f
--- /dev/null
+++ b/cli/tests/ts_type_only_import.ts.out
@@ -0,0 +1,4 @@
+Check [WILDCARD]ts_type_only_import.ts
+Warning Failed to get compiled source code of "[WILDCARD]ts_type_only_import.d.ts".
+Reason: [WILDCARD] (os error 2)
+If the source file provides only type exports, prefer to use "import type" or "export type" syntax instead.