Skip to content

Commit

Permalink
chore: checkin type-checks w/tsc (denoland#600)
Browse files Browse the repository at this point in the history
The lint step will actually type-check checkin and all of the extension
code in checkin.
  • Loading branch information
mmastrac committed Feb 24, 2024
1 parent 2104a7e commit a3bd7d0
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ jobs:

- name: Install ARM runner tools
if: ${{ inputs.os == 'ubuntu-22.04-arm64' }}
run: sudo apt update && sudo apt-get install -y unzip clang
run: |
sudo apt update && sudo apt-get install -y unzip clang
- name: Install Rust
uses: dsherret/rust-toolchain-file@v1
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci-lint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ runs:
run: |
cargo fmt -- --check
deno fmt --check ./core/ ./ops/ ./serde_v8/
- name: tsc
shell: bash
run: |
deno run --allow-read --allow-env npm:typescript@5.3.3/tsc --noEmit -p testing/tsconfig.json
- name: Lint
shell: bash
run: |
Expand Down
2 changes: 1 addition & 1 deletion core/01_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@
);
}

function ensureFastOps(keep) {
function ensureFastOps(keep = false) {
return new Proxy({}, {
get(_target, opName) {
const op = ops[opName];
Expand Down
2 changes: 1 addition & 1 deletion core/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ declare namespace __bootstrap {
* primordials.StringPrototypeStartsWith('thing', 'hello')
* ```
*/
declare namespace primordials {
namespace primordials {
type UncurryThis<T extends (this: unknown, ...args: unknown[]) => unknown> =
(self: ThisParameterType<T>, ...args: Parameters<T>) => ReturnType<T>;
type UncurryThisStaticApply<
Expand Down
2 changes: 1 addition & 1 deletion core/lib.deno_core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
declare namespace Deno {
namespace core {
/** Returns a proxy that generates the fast versions of sync and async ops. */
function ensureFastOps(): any;
function ensureFastOps(keep?: boolean): any;

/** Mark following promise as "ref", ie. event loop won't exit
* until all "ref" promises are resolved. All async ops are "ref" by default. */
Expand Down
30 changes: 29 additions & 1 deletion testing/checkin.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
/// <reference path="../core/lib.deno_core.d.ts" />
// TODO(mmastrac): make this typecheck
// <reference path="../core/internal.d.ts" />
/// <reference lib="dom" />

// deno-lint-ignore-file no-explicit-any

// Types and method unavailable in TypeScript by default.
interface PromiseConstructor {
withResolvers<T>(): {
promise: Promise<T>;
resolve: (value: T | PromiseLike<T>) => void;
// deno-lint-ignore no-explicit-any
reject: (reason?: any) => void;
};
}
Expand All @@ -24,3 +27,28 @@ declare namespace Deno {
export function refTimer(id);
export function unrefTimer(id);
}

declare module 'ext:core/mod.js' {
const core: any;
}

declare module 'ext:core/ops' {
function op_log_debug(...any): any;
function op_log_info(...any): any;

function op_test_register(...any): any;

function op_async_throw_error_deferred(...any): any;
function op_async_throw_error_eager(...any): any;
function op_async_throw_error_lazy(...any): any;
function op_error_context_async(...any): any;
function op_error_context_sync(...any): any;
function op_error_custom_sync(...any): any;

function op_worker_await_close(...any): any;
function op_worker_parent(...any): any;
function op_worker_recv(...any): any;
function op_worker_send(...any): any;
function op_worker_spawn(...any): any;
function op_worker_terminate(...any): any;
}
2 changes: 1 addition & 1 deletion testing/checkin/runtime/__init.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import * as throw_ from "checkin:throw";
testing;
async;
error;
throw_;

globalThis.console = console.console;
globalThis.setTimeout = timers.setTimeout;
globalThis.setInterval = timers.setInterval;
globalThis.clearTimeout = timers.clearTimeout;
globalThis.clearInterval = timers.clearInterval;
globalThis.Worker = worker.Worker;
globalThis.throwInExt = throw_.throwInExt;
Reflect.defineProperty(globalThis, "onerror", {
set: (cb) => {
if (cb) {
Expand Down
2 changes: 1 addition & 1 deletion testing/checkin/runtime/throw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/**
* This is needed to test that stack traces in extensions are correct.
*/
export function throwInExt() {
export function throwExceptionFromExtension() {
innerThrowInExt();
}

Expand Down
4 changes: 2 additions & 2 deletions testing/integration/error_ext_stack/error_ext_stack.out

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion testing/integration/error_ext_stack/error_ext_stack.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// FAIL
import { throwExceptionFromExtension } from "checkin:throw";

throwInExt();
throwExceptionFromExtension();
1 change: 1 addition & 0 deletions testing/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"checkin:console": ["checkin/runtime/console.ts"],
"checkin:error": ["checkin/runtime/error.ts"],
"checkin:testing": ["checkin/runtime/testing.ts"],
"checkin:throw": ["checkin/runtime/throw.ts"],
"checkin:timers": ["checkin/runtime/timers.ts"],
"checkin:worker": ["checkin/runtime/worker.ts"]
},
Expand Down

0 comments on commit a3bd7d0

Please sign in to comment.