From 69b132d159270efb698a709c5552a44f9af570b7 Mon Sep 17 00:00:00 2001 From: Charles Lowell Date: Fri, 13 Dec 2024 16:24:13 -0600 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Deno=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most everybody is running Deno 2 locally for development, so we want to make it work well. This updates the github workflows to use Deno 2, and also papers over some of the new TypeScript errors that are introduces by making catch blocks type their errors as `unknown` --- .github/workflows/npm-release.yml | 6 +++--- .github/workflows/verify.yaml | 6 +++--- lib/call.ts | 2 +- lib/context.ts | 2 +- lib/main.ts | 2 +- lib/race.ts | 2 +- lib/run/frame.ts | 4 ++-- test/queue.test.ts | 2 +- test/run.test.ts | 4 ++-- test/suite.ts | 2 +- 10 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/npm-release.yml b/.github/workflows/npm-release.yml index 93a92a73d..eee73b2a1 100644 --- a/.github/workflows/npm-release.yml +++ b/.github/workflows/npm-release.yml @@ -17,12 +17,12 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: setup deno - uses: denoland/setup-deno@v1 + uses: denoland/setup-deno@v2 with: - deno-version: v1.x + deno-version: v2.x - name: Get Version id: vars diff --git a/.github/workflows/verify.yaml b/.github/workflows/verify.yaml index 45436211a..5a0e2f836 100644 --- a/.github/workflows/verify.yaml +++ b/.github/workflows/verify.yaml @@ -15,12 +15,12 @@ jobs: steps: - name: checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: setup deno - uses: denoland/setup-deno@v1 + uses: denoland/setup-deno@v2 with: - deno-version: v1.46.x + deno-version: v2.x - name: Setup Node uses: actions/setup-node@v2 diff --git a/lib/call.ts b/lib/call.ts index 86e0662aa..fb9cfb892 100644 --- a/lib/call.ts +++ b/lib/call.ts @@ -123,7 +123,7 @@ export function call(callable: Callable): Operation { resolve(yield* toop(callable)); } } catch (error) { - reject(error); + reject(error as Error); } }); } diff --git a/lib/context.ts b/lib/context.ts index 39ac0612e..cc4ecd591 100644 --- a/lib/context.ts +++ b/lib/context.ts @@ -27,5 +27,5 @@ export function createContext(key: string, defaultValue?: T): Context { } class MissingContextError extends Error { - name = "MissingContextError"; + override name = "MissingContextError"; } diff --git a/lib/main.ts b/lib/main.ts index 68e366517..93e8fe516 100644 --- a/lib/main.ts +++ b/lib/main.ts @@ -113,7 +113,7 @@ export async function main( yield* exit(0); } catch (error) { - resolve({ status: 1, error }); + resolve({ status: 1, error: error as Error }); } finally { clearInterval(interval); } diff --git a/lib/race.ts b/lib/race.ts index d4e835634..1fbe82ac5 100644 --- a/lib/race.ts +++ b/lib/race.ts @@ -33,7 +33,7 @@ export function race>( try { resolve((yield* operation) as Yielded); } catch (error) { - reject(error); + reject(error as Error); } }); } diff --git a/lib/run/frame.ts b/lib/run/frame.ts index 0e15967e6..19b69722e 100644 --- a/lib/run/frame.ts +++ b/lib/run/frame.ts @@ -98,7 +98,7 @@ export function createFrame(options: FrameOptions): Frame { result: yield* instruction(frame), }); } catch (error) { - k.tail({ type: "settled", result: Err(error) }); + k.tail({ type: "settled", result: Err(error as Error) }); } }); @@ -117,7 +117,7 @@ export function createFrame(options: FrameOptions): Frame { } } } catch (error) { - thunks.unshift({ done: true, value: Err(error) }); + thunks.unshift({ done: true, value: Err(error as Error) }); } thunk = thunks.pop()!; } diff --git a/test/queue.test.ts b/test/queue.test.ts index 44282ed5d..b456fa1f5 100644 --- a/test/queue.test.ts +++ b/test/queue.test.ts @@ -58,7 +58,7 @@ function abortAfter(op: Operation, ms: number): Operation { try { resolve(yield* op); } catch (error) { - reject(error); + reject(error as Error); } }); yield* sleep(ms); diff --git a/test/run.test.ts b/test/run.test.ts index 52c803a95..c764d389b 100644 --- a/test/run.test.ts +++ b/test/run.test.ts @@ -257,7 +257,7 @@ describe("run()", () => { }); throw new Error("expected error to propagate"); } catch (error) { - expect(error.message).toEqual("boom"); + expect((error as Error).message).toEqual("boom"); } }); @@ -268,7 +268,7 @@ describe("run()", () => { }); throw new Error("expected error to propagate"); } catch (error) { - expect(error.message).toEqual("boom"); + expect((error as Error).message).toEqual("boom"); } }); diff --git a/test/suite.ts b/test/suite.ts index 2e9f292c6..3f89295eb 100644 --- a/test/suite.ts +++ b/test/suite.ts @@ -96,7 +96,7 @@ export function useCommand( if ( !!error && - !error.message.includes("Child process has already terminated") + !(error as Error).message.includes("Child process has already terminated") ) { // deno-lint-ignore no-unsafe-finally throw error;