summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-04-16 16:46:31 -0400
committerGitHub <noreply@github.com>2024-04-16 16:46:31 -0400
commit43c8c1cc6e0f0fe4accde97c52f7f2bb998ac669 (patch)
tree157e9e3801253b1ad9345aded73e684a39292bc5 /tests
parent422cff1f247dc334d5eb9387be924f5937b0c6d9 (diff)
feat(check): allow using side effect imports with unknown module kinds (ex. css modules) (#23392)
This allows people to use imports like: ```ts import "./app.css"; ``` ...with `deno check` in systems where there's a bundle step (ex. Vite). This will still error when using it with `deno run` or if the referenced file does not exist. See test cases for behaviour.
Diffstat (limited to 'tests')
-rw-r--r--tests/specs/check/css_import/__test__.jsonc24
-rw-r--r--tests/specs/check/css_import/app.css0
-rw-r--r--tests/specs/check/css_import/exists.out1
-rw-r--r--tests/specs/check/css_import/exists.ts2
-rw-r--r--tests/specs/check/css_import/exists_and_try_uses.out5
-rw-r--r--tests/specs/check/css_import/exists_and_try_uses.ts3
-rw-r--r--tests/specs/check/css_import/exists_dynamic_import.ts3
-rw-r--r--tests/specs/check/css_import/exists_run_with_check.out3
-rw-r--r--tests/specs/check/css_import/not_exists.out2
-rw-r--r--tests/specs/check/css_import/not_exists.ts1
10 files changed, 44 insertions, 0 deletions
diff --git a/tests/specs/check/css_import/__test__.jsonc b/tests/specs/check/css_import/__test__.jsonc
new file mode 100644
index 000000000..629dcd383
--- /dev/null
+++ b/tests/specs/check/css_import/__test__.jsonc
@@ -0,0 +1,24 @@
+{
+ "steps": [{
+ "args": "check exists.ts",
+ "output": "exists.out"
+ }, {
+ "args": "run --check exists.ts",
+ "output": "exists_run_with_check.out",
+ "exitCode": 1
+ }, {
+ "args": "check not_exists.ts",
+ "output": "not_exists.out",
+ "exitCode": 1
+ }, {
+ "args": "check exists_and_try_uses.ts",
+ "output": "exists_and_try_uses.out",
+ "exitCode": 1
+ }, {
+ "args": "check exists_dynamic_import.ts",
+ "output": "Check file:///[WILDCARD]exists_dynamic_import.ts\n"
+ }, {
+ "args": "run --check --reload exists_dynamic_import.ts",
+ "output": "Check file:///[WILDCARD]exists_dynamic_import.ts\n"
+ }]
+}
diff --git a/tests/specs/check/css_import/app.css b/tests/specs/check/css_import/app.css
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/tests/specs/check/css_import/app.css
diff --git a/tests/specs/check/css_import/exists.out b/tests/specs/check/css_import/exists.out
new file mode 100644
index 000000000..1e9af3607
--- /dev/null
+++ b/tests/specs/check/css_import/exists.out
@@ -0,0 +1 @@
+Check [WILDLINE]exists.ts
diff --git a/tests/specs/check/css_import/exists.ts b/tests/specs/check/css_import/exists.ts
new file mode 100644
index 000000000..d5e05ae67
--- /dev/null
+++ b/tests/specs/check/css_import/exists.ts
@@ -0,0 +1,2 @@
+// should not error for deno check
+import "./app.css";
diff --git a/tests/specs/check/css_import/exists_and_try_uses.out b/tests/specs/check/css_import/exists_and_try_uses.out
new file mode 100644
index 000000000..b51ea2391
--- /dev/null
+++ b/tests/specs/check/css_import/exists_and_try_uses.out
@@ -0,0 +1,5 @@
+Check file:///[WILDLINE]/exists_and_try_uses.ts
+error: TS1192 [ERROR]: Module '"file:///[WILDLINE]/app.css"' has no default export.
+import test from "./app.css";
+ ~~~~
+ at file:///[WILDLINE]/exists_and_try_uses.ts:1:8
diff --git a/tests/specs/check/css_import/exists_and_try_uses.ts b/tests/specs/check/css_import/exists_and_try_uses.ts
new file mode 100644
index 000000000..afaa6e4e0
--- /dev/null
+++ b/tests/specs/check/css_import/exists_and_try_uses.ts
@@ -0,0 +1,3 @@
+import test from "./app.css";
+
+test(123);
diff --git a/tests/specs/check/css_import/exists_dynamic_import.ts b/tests/specs/check/css_import/exists_dynamic_import.ts
new file mode 100644
index 000000000..14f63fd23
--- /dev/null
+++ b/tests/specs/check/css_import/exists_dynamic_import.ts
@@ -0,0 +1,3 @@
+if (false) {
+ await import("./app.css");
+}
diff --git a/tests/specs/check/css_import/exists_run_with_check.out b/tests/specs/check/css_import/exists_run_with_check.out
new file mode 100644
index 000000000..1a1dafeb7
--- /dev/null
+++ b/tests/specs/check/css_import/exists_run_with_check.out
@@ -0,0 +1,3 @@
+error: Expected a JavaScript or TypeScript module, but identified a Unknown module. Importing these types of modules is currently not supported.
+ Specifier: file:///[WILDLINE]/app.css
+ at file:///[WILDLINE]/exists.ts:2:8
diff --git a/tests/specs/check/css_import/not_exists.out b/tests/specs/check/css_import/not_exists.out
new file mode 100644
index 000000000..95fd14668
--- /dev/null
+++ b/tests/specs/check/css_import/not_exists.out
@@ -0,0 +1,2 @@
+error: Module not found "file:///[WILDLINE]/not_exists.css".
+ at file:///[WILDLINE]/not_exists.ts:1:8
diff --git a/tests/specs/check/css_import/not_exists.ts b/tests/specs/check/css_import/not_exists.ts
new file mode 100644
index 000000000..762c9acd7
--- /dev/null
+++ b/tests/specs/check/css_import/not_exists.ts
@@ -0,0 +1 @@
+import "./not_exists.css";