-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(unstable): fast subset type checking of JSR dependencies (#21873)
- Loading branch information
Showing
42 changed files
with
714 additions
and
149 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0/mod.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
5 changes: 5 additions & 0 deletions
5
cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/0.1.0_meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"exports": { | ||
".": "./mod.ts" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
cli/tests/testdata/jsr/registry/@denotest/subset_type_graph/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"versions": { | ||
"0.1.0": {} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0/mod.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |
5 changes: 5 additions & 0 deletions
5
cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/0.1.0_meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"exports": { | ||
".": "./mod.ts" | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
cli/tests/testdata/jsr/registry/@denotest/subset_type_graph_invalid/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"versions": { | ||
"0.1.0": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Foo as Foo1 } from "jsr:@denotest/[email protected]"; | ||
import { Foo as Foo2 } from "jsr:@denotest/[email protected]"; | ||
|
||
// 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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Checking fast check type graph for errors... | ||
|
||
Missing explicit return type in the public API. | ||
at file:///[WILDCARD]/publish/invalid_fast_check/mod.ts:2:17 | ||
|
||
Fixing these fast check errors is required to make the code fast check compatible which enables type checking your package's TypeScript code with the same performance as if you had distributed declaration files. Do any of these errors seem too restrictive or incorrect? Please open an issue if so to help us improve: https://github.com/denoland/deno/issues | ||
|
||
error: Had 1 fast check error. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "@foo/bar", | ||
"version": "1.1.0", | ||
"exports": { | ||
".": "./mod.ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// requires an explicit type annotation of `number` | ||
export function getRandom() { | ||
return Math.random(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Checking fast check type graph for errors... | ||
Ensuring type checks... | ||
Check file:///[WILDCARD]/javascript_decl_file/mod.js | ||
Publishing @foo/[email protected] ... | ||
Successfully published @foo/[email protected] | ||
Visit http://127.0.0.1:4250/@foo/[email protected] for details |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "@foo/bar", | ||
"version": "1.0.0", | ||
"exports": { | ||
".": "./mod.js" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export function getRandom(): number; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/// <reference types="./mod.d.ts" /> | ||
|
||
export function getRandom() { | ||
return Math.random(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Checking fast check type graph for errors... | ||
Warning Package '@foo/bar' is a JavaScript package without a corresponding declaration file. This may lead to a non-optimal experience for users of your package. For performance reasons, it's recommended to ship a corresponding TypeScript declaration file or to convert to TypeScript. | ||
Ensuring type checks... | ||
Publishing @foo/[email protected] ... | ||
Successfully published @foo/[email protected] | ||
Visit http://127.0.0.1:4250/@foo/[email protected] for details |
8 changes: 8 additions & 0 deletions
8
cli/tests/testdata/publish/javascript_missing_decl_file/deno.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"name": "@foo/bar", | ||
"version": "1.0.0", | ||
"exports": { | ||
".": "./mod.js", | ||
"./other": "./other.js" | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
cli/tests/testdata/publish/javascript_missing_decl_file/mod.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function getRandom() { | ||
return Math.random(); | ||
} |
3 changes: 3 additions & 0 deletions
3
cli/tests/testdata/publish/javascript_missing_decl_file/other.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function other() { | ||
return Math.random(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function add(a: number, b: number): number { | ||
return a + b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
Checking fast check type graph for errors... | ||
Ensuring type checks... | ||
Check file:///[WILDCARD]/publish/successful/mod.ts | ||
Publishing @foo/[email protected] ... | ||
Successfully published @foo/[email protected] | ||
Visit http://127.0.0.1:4250/@foo/[email protected] for details |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,6 @@ | |
".": "./mod.ts" | ||
}, | ||
"imports": { | ||
"@std/http": "jsr:@std/http@1" | ||
"@std/http": "./std_http.ts" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import http from "@std/http"; | ||
|
||
export function foobar() { | ||
export function foobar(): { fileServer(): void } { | ||
return http.fileServer; | ||
} |
Oops, something went wrong.