summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2022-11-25 13:42:05 -0500
committerGitHub <noreply@github.com>2022-11-25 13:42:05 -0500
commitd0a4e23ae824baf1994291d8480be29719f1b99a (patch)
treec7d608596c29df0fa0d8b87d527d6897759a79fc /cli/tests
parent8fc62f93bfeb63edf2ee875ee5d4f8b63728f838 (diff)
fix(npm): better error message when attempting to use typescript in npm packages (#16813)
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/npm_tests.rs8
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/typescript-file/1.0.0/index.ts4
-rw-r--r--cli/tests/testdata/npm/registry/@denotest/typescript-file/1.0.0/package.json5
-rw-r--r--cli/tests/testdata/npm/typescript_file_in_package/main.out6
-rw-r--r--cli/tests/testdata/npm/typescript_file_in_package/main.ts5
5 files changed, 28 insertions, 0 deletions
diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs
index ea577d412..288500ce4 100644
--- a/cli/tests/integration/npm_tests.rs
+++ b/cli/tests/integration/npm_tests.rs
@@ -314,6 +314,14 @@ itest!(types_no_types_entry {
exit_code: 0,
});
+itest!(typescript_file_in_package {
+ args: "run npm/typescript_file_in_package/main.ts",
+ output: "npm/typescript_file_in_package/main.out",
+ envs: env_vars(),
+ http_server: true,
+ exit_code: 1,
+});
+
#[test]
fn parallel_downloading() {
let (out, _err) = util::run_and_collect_output_with_args(
diff --git a/cli/tests/testdata/npm/registry/@denotest/typescript-file/1.0.0/index.ts b/cli/tests/testdata/npm/registry/@denotest/typescript-file/1.0.0/index.ts
new file mode 100644
index 000000000..44b441a1e
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/typescript-file/1.0.0/index.ts
@@ -0,0 +1,4 @@
+// this should not work because we don't support typescript files in npm packages
+export function getValue(): 5 {
+ return 5;
+} \ No newline at end of file
diff --git a/cli/tests/testdata/npm/registry/@denotest/typescript-file/1.0.0/package.json b/cli/tests/testdata/npm/registry/@denotest/typescript-file/1.0.0/package.json
new file mode 100644
index 000000000..e899f4100
--- /dev/null
+++ b/cli/tests/testdata/npm/registry/@denotest/typescript-file/1.0.0/package.json
@@ -0,0 +1,5 @@
+{
+ "name": "@denotest/typescript-file",
+ "version": "1.0.0",
+ "main": "./index.ts"
+}
diff --git a/cli/tests/testdata/npm/typescript_file_in_package/main.out b/cli/tests/testdata/npm/typescript_file_in_package/main.out
new file mode 100644
index 000000000..ba53f7725
--- /dev/null
+++ b/cli/tests/testdata/npm/typescript_file_in_package/main.out
@@ -0,0 +1,6 @@
+Download http://localhost:4545/npm/registry/@denotest/typescript-file
+Download http://localhost:4545/npm/registry/@denotest/typescript-file/1.0.0.tgz
+error: Could not resolve 'npm:@denotest/typescript-file'.
+
+Caused by:
+ TypeScript files are not supported in npm packages: file:///[WILDCARD]/@denotest/typescript-file/1.0.0/index.ts
diff --git a/cli/tests/testdata/npm/typescript_file_in_package/main.ts b/cli/tests/testdata/npm/typescript_file_in_package/main.ts
new file mode 100644
index 000000000..aefc38ebe
--- /dev/null
+++ b/cli/tests/testdata/npm/typescript_file_in_package/main.ts
@@ -0,0 +1,5 @@
+// We don't support typescript files in npm packages because we don't
+// want to encourage people distributing npm packages that aren't JavaScript.
+import { getValue } from "npm:@denotest/typescript-file";
+
+console.log(getValue());