Skip to content

Commit

Permalink
⬆️ Deno 2
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
cowboyd committed Dec 13, 2024
1 parent 4982887 commit c227c85
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 17 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/npm-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@ 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
run: echo ::set-output name=version::$(echo ${{github.ref_name}} | sed 's/^effection-v//')


- name: Setup Node
uses: actions/setup-node@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/verify.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export function call<T>(callable: Callable<T>): Operation<T> {
resolve(yield* toop(callable));
}
} catch (error) {
reject(error);
reject(error as Error);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion lib/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ export function createContext<T>(key: string, defaultValue?: T): Context<T> {
}

class MissingContextError extends Error {
name = "MissingContextError";
override name = "MissingContextError";
}
2 changes: 1 addition & 1 deletion lib/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/race.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function race<T extends Operation<unknown>>(
try {
resolve((yield* operation) as Yielded<T>);
} catch (error) {
reject(error);
reject(error as Error);
}
});
}
Expand Down
4 changes: 2 additions & 2 deletions lib/run/frame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function createFrame<T>(options: FrameOptions<T>): Frame<T> {
result: yield* instruction(frame),
});
} catch (error) {
k.tail({ type: "settled", result: Err(error) });
k.tail({ type: "settled", result: Err(error as Error) });
}
});

Expand All @@ -117,7 +117,7 @@ export function createFrame<T>(options: FrameOptions<T>): Frame<T> {
}
}
} catch (error) {
thunks.unshift({ done: true, value: Err(error) });
thunks.unshift({ done: true, value: Err(error as Error) });
}
thunk = thunks.pop()!;
}
Expand Down
2 changes: 1 addition & 1 deletion test/queue.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function abortAfter<T>(op: Operation<T>, ms: number): Operation<T | void> {
try {
resolve(yield* op);
} catch (error) {
reject(error);
reject(error as Error);
}
});
yield* sleep(ms);
Expand Down
4 changes: 2 additions & 2 deletions test/run.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
});

Expand All @@ -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");
}
});

Expand Down
4 changes: 3 additions & 1 deletion test/suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ 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;
Expand Down

0 comments on commit c227c85

Please sign in to comment.