docs.rs failed to build pctx_type_check_runtime-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
PCTX Type Check
An isolated TypeScript type checking runtime powered by Deno and the official TypeScript compiler.
Quick Start
use ;
// Async API (preferred)
let code = r#"
const x: number = 42;
const y: string = "hello";
export default x + y.length;
"#;
let result = type_check_async.await?;
if result.success else
// Sync API (creates tokio runtime if needed)
let result = type_check?;
API Reference
Core Functions
type_check_async(code: &str) -> Result<CheckResult>
Asynchronously type check TypeScript code. Preferred API for async contexts.
let result = type_check_async.await?;
assert!;
type_check(code: &str) -> Result<CheckResult>
Synchronously type check TypeScript code. Creates a tokio runtime if needed.
let result = type_check?;
assert!;
is_relevant_error(diagnostic: &Diagnostic) -> bool
Filter diagnostics to only include errors that would cause runtime failures.
let errors: = result.diagnostics
.into_iter
.filter
.collect;
Types
CheckResult
Diagnostic
TypeCheckError
Examples
Catching Type Errors
let code = r#"
const x: number = "string"; // Type error!
export default x;
"#;
let result = type_check_async.await?;
assert!;
assert_eq!; // Type mismatch
Architecture
- Build Phase: TypeScript compiler (9MB) is embedded in a V8 snapshot via
build.rs - Runtime Phase: Each type check creates an isolated Deno runtime with the snapshot
- Type Checking: Runtime executes
ts.createProgram()andgetSemanticDiagnostics() - Cleanup: Runtime is dropped after check, freeing all memory
Snapshot Contents
The V8 snapshot includes:
- TypeScript 5.3.3 compiler (full semantic analysis)
- Minimal
lib.d.tsdefinitions (Promise, Array, console, etc.) - MCP SDK type definitions
- Type checking orchestration logic
Filtered Error Codes
See is_relevant_error() for a full list of typescript codes that are ignored