Deno based type Guard Code Generator

Deno based type Guard Code Generator

Denoguard .Deno based type guard code generator.


Deno based type guard code generator.


Type guard code generation tool written for DenoJs.


This tool is written using DenoJs.


To run the tool invoke it with the --unstable and --allow-read options.

The test-interfaces.ts file has some example input source code to use during development for testing. For example to run the tool on this file:

deno run --allow-read --unstable main.ts -f test-interfaces.ts 


To test the tool run with the --unstable option:

deno test --unstable

Code Generation

This tool parses source files for interface definitions using the same parser that Deno uses (SWC). It then generates Typescript type guards for these interfaces. The type guards are named is<interface name> (The <interface name> will have it's first letter capitalized).

Interface type guards are constructed by combining smaller pre-defined and tested type guards, which we will call sub type guards. Each of these sub type guards test one property of an unknown type. The code generator determines what properties of an interface need to be tested and combines the appropriate sub type guards together to satisfy an interface's requirements.

These sub type guards reside in the guards.ts file. When Denoguard itself is built this guard.ts file is parsed (using the same SWC Typescript parser) and each sub type guard's abstract syntax tree is slightly transformed. The transformation ensures the sub type guard functions are ready for code generation purposes by removing export keywords from before function definitions. Then in preparation for Denoguard code generation the resulting sub type guard's Typescript source code strings are saved to the guards_generated.ts file, which will included in the final Denoguard bundle distribution.

This process ensures that type guards can be tested and are reliable.

Download Details:

Author: Screeos

Source Code:

deno nodejs node javascript

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

AEM Querybuilder for JavaScript (Browser, Node, Deno)

Helix Querybuilder .AEM Querybuilder for JavaScript (Browser, Node, Deno)

NKeys for JavaScript - Node.js, Browsers, and Deno

A public-key signature system based on Ed25519 for the NATS ecosystem system for JavaScript. The nkeys.js library works in Deno, Node.js, and the browser!

Javascript module for easily generating mazes,compatible with both Deno and Node

A work-in-progress Javascript maze generator module, compatible with both Deno and Node.

Deno Tutorial for Beginners: Deno vs. Node: Better Than NodeJS?

Deno is released, it’s time to find out if it can prove a worthy competition for Node.js. What is Deno? Why Deno can be considered an alternative to Node? The main differences between Deno and Node. Write a simple Deno app.

What is Deno? The Node.JS Killer? The Deno-minator to Node?

What is Deno? The Node.JS Killer? The Deno-minator to Node? Deno is the new hype and will it be better than node.js? Deno is a secure runtime for JavaScript and TypeScript that is based on the V8 JavaScript engine and the Rust programming language that addresses Node’s shortcomings