Skip to content

Commit 4d35e6c

Browse files
committed
chore: actually typecheck deno files, fix errors
We weren't including Deno files in `tsc` typechecking, but we also weren't using any `deno` commands that typecheck. This introduces typechecking in CI and fixes resulting hidden errors. The JSON hack isn't great but really it's the whole "import a json and write new data to it" pattern that should be simplified to "just read the new data in memory", since there's no actual reason to write it to disk if you follow the code paths. It was just done that way because it was the shortest path to add the dynamic fissue annotation from the previous implementation.
1 parent 850ee8a commit 4d35e6c

File tree

6 files changed

+46
-16
lines changed

6 files changed

+46
-16
lines changed

.github/workflows/deno-test.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,9 @@ jobs:
1212
uses: denoland/setup-deno@v1
1313
with:
1414
deno-version: vx.x.x
15+
- name: Typecheck
16+
run: npm run typecheck:deno
17+
- name: Lint
18+
run: npm run lint:deno
1519
- name: Test
16-
run: deno test -A edge-runtime/
20+
run: npm run test:deno

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ jobs:
3434
- name: Lint
3535
# github adds inline annotation for compact or stylish format
3636
# which is different than our default for local usage
37-
run: npm run lint -- --format=compact
37+
run: npm run lint:node -- --format=compact
3838
- name: Types
39-
run: npm run typecheck
39+
run: npm run typecheck:node
4040
# we still want to check types if lint fails just to know everything
4141
# and not peel errors to uncover new ones of different type
4242
if: always()

deno.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

deno.jsonc

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"exclude": [
3+
"edge-runtime/vendor/",
4+
"edge-runtime/shim/"
5+
],
6+
"lint": {
7+
"include": [
8+
"tools/deno/",
9+
"edge-runtime/"
10+
],
11+
"exclude": [
12+
// TODO(serhalp) Remove this exclusion and fix the lint errors here.
13+
"edge-runtime/lib"
14+
]
15+
},
16+
"test": {
17+
"include": [
18+
"tools/deno/",
19+
"edge-runtime/"
20+
]
21+
},
22+
"tasks": {
23+
// TODO(serhalp) Add `edge-runtime/**/*.ts` and add a vendoring step in CI.
24+
"typecheck": "deno check tools/deno/**/*.ts"
25+
},
26+
"imports": {
27+
"@netlify/edge-functions": "https://edge.netlify.com/v1/index.ts"
28+
}
29+
}

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
"pretest:integration": "npm run build && node tests/prepare.mjs",
2020
"build": "node ./tools/build.js",
2121
"build:watch": "node ./tools/build.js --watch",
22-
"lint": "eslint --cache --format=codeframe --max-warnings=0 --ext .ts,.cts,.js src",
22+
"lint:node": "eslint --cache --format=codeframe --max-warnings=0 --ext .ts,.cts,.js src",
23+
"lint:deno": "deno lint",
24+
"lint": "npm run lint:node && npm run lint:deno",
2325
"format:fix": "prettier --write .",
2426
"format:check": "prettier --check .",
2527
"test": "vitest",
@@ -30,7 +32,10 @@
3032
"test:ci:unit-and-integration": "vitest run --reporter=default --retry=3 --project=unit --project=integration",
3133
"test:ci:smoke": "vitest run --reporter=default --retry=3 --project=smoke",
3234
"test:ci:e2e": "playwright test",
33-
"typecheck": "tsc --noEmit"
35+
"test:deno": "deno test -A",
36+
"typecheck:node": "tsc --noEmit",
37+
"typecheck:deno": "deno task typecheck",
38+
"typecheck": "npm run typecheck:node && npm run typecheck:deno"
3439
},
3540
"repository": {
3641
"type": "git",

tests/test-config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@
124124
{
125125
"file": "test/e2e/app-dir/app-static/app-static.test.ts",
126126
"reason": "Uses CLI output",
127-
"tests": ["app-dir static/dynamic handling should warn for too many cache tags"]
127+
"tests": [
128+
"app-dir static/dynamic handling should warn for too many cache tags"
129+
]
128130
},
129131
{
130132
"file": "test/e2e/app-dir/parallel-routes-and-interception/parallel-routes-and-interception.test.ts",

0 commit comments

Comments
 (0)