summaryrefslogtreecommitdiff
path: root/cli/tests/testdata/jsr
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-01-10 17:40:30 -0500
committerGitHub <noreply@github.com>2024-01-10 22:40:30 +0000
commit70ac06138c18cf643e7e1947dee54f3adff13de3 (patch)
tree73cd8fb7fe51ecbdcf47770b15b27f6fb49b4d05 /cli/tests/testdata/jsr
parent515a34b4de222e35c7ade1b92614d746e73d4c2e (diff)
feat(unstable): fast subset type checking of JSR dependencies (#21873)
Diffstat (limited to 'cli/tests/testdata/jsr')
-rw-r--r--cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0/mod.ts17
-rw-r--r--cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0_meta.json5
-rw-r--r--cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/meta.json5
-rw-r--r--cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0/mod.ts12
-rw-r--r--cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0_meta.json5
-rw-r--r--cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/meta.json5
-rw-r--r--cli/tests/testdata/jsr/subset_type_graph/main.check.out45
-rw-r--r--cli/tests/testdata/jsr/subset_type_graph/main.ts13
8 files changed, 107 insertions, 0 deletions
diff --git a/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0/mod.ts b/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0/mod.ts
new file mode 100644
index 000000000..e81b2309a
--- /dev/null
+++ b/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0/mod.ts
@@ -0,0 +1,17 @@
+// add some statements that will be removed by the subset
+// type graph so that we can test that the source map works
+console.log(1);
+console.log(2);
+console.log(3);
+
+export class Foo {
+ method(): number {
+ return Math.random();
+ }
+}
+
+// this won't be type checked against because the subset
+// type graph omit this code because it's not part of the
+// public API.
+const invalidTypeCheck: number = "";
+console.log(invalidTypeCheck);
diff --git a/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0_meta.json b/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0_meta.json
new file mode 100644
index 000000000..631a18d0e
--- /dev/null
+++ b/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0_meta.json
@@ -0,0 +1,5 @@
+{
+ "exports": {
+ ".": "./mod.ts"
+ }
+}
diff --git a/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/meta.json b/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/meta.json
new file mode 100644
index 000000000..d10aa5c3a
--- /dev/null
+++ b/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/meta.json
@@ -0,0 +1,5 @@
+{
+ "versions": {
+ "0.1.0": {}
+ }
+}
diff --git a/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0/mod.ts b/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0/mod.ts
new file mode 100644
index 000000000..6a5036bf5
--- /dev/null
+++ b/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0/mod.ts
@@ -0,0 +1,12 @@
+export class Foo {
+ method() {
+ return Math.random();
+ }
+}
+
+// This will be analyzed because the method above is missing an
+// explicit type which is required for the subset type graph to take
+// effect. So the entire source file will be type checked against,
+// causing a type error here.
+const invalidTypeCheck: number = "";
+console.log(invalidTypeCheck);
diff --git a/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0_meta.json b/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0_meta.json
new file mode 100644
index 000000000..631a18d0e
--- /dev/null
+++ b/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0_meta.json
@@ -0,0 +1,5 @@
+{
+ "exports": {
+ ".": "./mod.ts"
+ }
+}
diff --git a/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/meta.json b/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/meta.json
new file mode 100644
index 000000000..d10aa5c3a
--- /dev/null
+++ b/cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/meta.json
@@ -0,0 +1,5 @@
+{
+ "versions": {
+ "0.1.0": {}
+ }
+}
diff --git a/cli/tests/testdata/jsr/subset_type_graph/main.check.out b/cli/tests/testdata/jsr/subset_type_graph/main.check.out
new file mode 100644
index 000000000..fc4539c8a
--- /dev/null
+++ b/cli/tests/testdata/jsr/subset_type_graph/main.check.out
@@ -0,0 +1,45 @@
+Download http://localhost:4545/jsr/registry/@denotest/subset_type_graph/meta.json
+Download http://localhost:4545/jsr/registry/@denotest/subset_type_graph_invalid/meta.json
+Download http://localhost:4545/jsr/registry/@denotest/subset_type_graph/0.1.0_meta.json
+Download http://localhost:4545/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0_meta.json
+[UNORDERED_START]
+Download http://localhost:4545/jsr/registry/@denotest/subset_type_graph/0.1.0/mod.ts
+Download http://localhost:4545/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0/mod.ts
+[UNORDERED_END]
+Check file:///[WILDCARD]/subset_type_graph/main.ts
+error: TS2322 [ERROR]: Type 'string' is not assignable to type 'number'.
+const invalidTypeCheck: number = "";
+ ~~~~~~~~~~~~~~~~
+ at http://localhost:4545/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0/mod.ts:11:7
+
+TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
+const error1: string = new Foo1().method();
+ ~~~~~~
+ at file:///[WILDCARD]/subset_type_graph/main.ts:5:7
+
+TS2322 [ERROR]: Type 'number' is not assignable to type 'string'.
+const error2: string = new Foo2().method();
+ ~~~~~~
+ at file:///[WILDCARD]/subset_type_graph/main.ts:6:7
+
+TS2551 [ERROR]: Property 'method2' does not exist on type 'Foo'. Did you mean 'method'?
+new Foo1().method2();
+ ~~~~~~~
+ at file:///[WILDCARD]/subset_type_graph/main.ts:12:12
+
+ 'method' is declared here.
+ method(): number {
+ ~~~~~~
+ at http://localhost:4545/jsr/registry/@denotest/subset_type_graph/0.1.0/mod.ts:8:3
+
+TS2551 [ERROR]: Property 'method2' does not exist on type 'Foo'. Did you mean 'method'?
+new Foo2().method2();
+ ~~~~~~~
+ at file:///[WILDCARD]/subset_type_graph/main.ts:13:12
+
+ 'method' is declared here.
+ method() {
+ ~~~~~~
+ at http://localhost:4545/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0/mod.ts:2:3
+
+Found 5 errors.
diff --git a/cli/tests/testdata/jsr/subset_type_graph/main.ts b/cli/tests/testdata/jsr/subset_type_graph/main.ts
new file mode 100644
index 000000000..2e1614be9
--- /dev/null
+++ b/cli/tests/testdata/jsr/subset_type_graph/main.ts
@@ -0,0 +1,13 @@
+import { Foo as Foo1 } from "jsr:@denotest/subset_type_graph@0.1.0";
+import { Foo as Foo2 } from "jsr:@denotest/subset_type_graph_invalid@0.1.0";
+
+// these will both raise type checking errors
+const error1: string = new Foo1().method();
+const error2: string = new Foo2().method();
+console.log(error1);
+console.log(error2);
+
+// now raise some errors that will show the original code and
+// these should source map to the original
+new Foo1().method2();
+new Foo2().method2();