Skip to content

Repository files navigation

Jint.TypeScript

TypeScript scripting for .NET applications. Let users customize business rules, validate data, and automate workflows with TypeScript, then run their scripts inside your application with Jint.

  • A better editing experience. Use interfaces, generics, and type annotations for IntelliSense, navigation, and type checking in your editor.
  • Native .NET execution. Parse TypeScript in C# with no Node.js runtime or JavaScript transpiler in the execution path.
  • Reusable scripts and modules. Prepare scripts once for repeated execution and load imports from a directory or virtual files.
  • Incremental adoption. Run existing JavaScript scripts and add TypeScript annotations as you go.

See it in action

The Monaco playground includes working pricing, validation, and webhook examples. Edit multiple files with TypeScript IntelliSense, import helpers, and run scripts against JSON input with results and host logs. There's also a JSDoc migration example that converts supported annotations and switches editor modes in one action.

TypeScript IntelliSense for the imported Quote interface, with execution results and host logs in the playground

Use it in your application

Install the preview package, then prepare a rule and pass in your application data:

using Jint;
using Jint.TypeScript;

var compiler = new TypeScriptCompiler();
var rule = compiler.PrepareScript("""
    interface Order { subtotal: number; preferredCustomer: boolean; }
    declare const order: Order;

    order.preferredCustomer || order.subtotal >= 100 ? 0 : 5;
    """, "shipping.ts");

var order = new { subtotal = 75, preferredCustomer = false };
var shippingCost = new Engine().SetValue("order", order).Evaluate(rule).AsNumber(); // 5

Reuse rule for subsequent orders without parsing it again. See the usage guide for module loading, JavaScript migration, diagnostics, and supported syntax.

Experimental: targets .NET 8 and .NET 10 with Jint 5 previews. Supports erasable TypeScript syntax; types are checked by your editor or tsc, not at runtime. Features requiring generated runtime code, such as enums and constructor parameter properties, are unsupported. See limitations and enum alternatives.

Built on Acornima, with a focused parser fork for TypeScript support. Read how it differs from Acornima and the performance measurements.

Apache-2.0, with imported components under their respective licenses. See LICENSE and third-party notices.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages