Comprehensive TypeScript definitions for the Frappe Framework’s client-side JavaScript API.
This package provides fully-typed global variables and functions commonly injected by Frappe in the browser such as frappe, cur_frm, __, msgprint, and much more, allowing you to write modern, type-safe custom Frappe apps with confidence.
- About
- What’s Included?
- Getting Started
- Installation
- Setup
- Usage
- Deployment
- Built Using
- Contributing
- Authors
- Acknowledgments
The Frappe Framework offers a powerful client-side API — but it’s built around plain JavaScript, which comes with common issues:
- ❌ Typing mistakes (e.g.
frm.doc.customer_namevsfrm.doc.customer_nam) - ❌ No clarity on the shape of API responses
- ❌ Fragile code during refactors
- ❌ Poor autocomplete and inline documentation
With @anygridtech/frappe-types, you get:
- ✅ Accurate autocompletion
- ✅ Compile-time error checking
- ✅ Inline documentation support
- ✅ Improved code maintainability and developer experience
-
frappe– Core Frappe namespace with:frappe.call()– Server-side RPC method callsfrappe.db– Database operations (get_list, get_value, insert, etc.)frappe.ui– UI components (Dialog, Form, Scanner, ScriptManager)frappe.model– Document model utilitiesfrappe.utils– Utility functions (nowdate, get_random, icon, eval, play_sound)frappe.boot– Boot configuration and cached datafrappe.datetime– Date and time utilitiesfrappe.dom– DOM manipulation helpersfrappe.msgprint()– Display alert messagesfrappe.show_alert()– Floating notification alertsfrappe.confirm()– Confirmation dialogsfrappe.prompt()– User input promptsfrappe.throw()– Error throwing with UI feedbackfrappe.get_doc()– Fetch documents from local cachefrappe.get_meta()– Get DocType metadatafrappe.new_doc()– Create and navigate to new documentsfrappe.set_route()/frappe.get_route()– Routing utilitiesfrappe.require()/frappe.provide()– Asset and namespace managementfrappe.session– Current user session info
-
cur_frm– Current form instance with:cur_frm.doc– Document datacur_frm.set_value()– Set field valuescur_frm.get_field()– Access field objectscur_frm.add_custom_button()– Add form buttonscur_frm.refresh_field()– Refresh specific fieldscur_frm.save()/cur_frm.reload_doc()– Form operations- Plus many more form methods and properties
-
__– Translation/internationalization function
FrappeDoc– Base document interface with standard fieldsFrappeForm<T>– Strongly-typed form interfaceDocMeta– DocType metadata structureDialogInstance– Dialog component types- UI Components: Dialog, Form, Scanner, ScriptManager
Pre-built type definitions for common DocTypes:
- Frappe Core: Company
- ERPNext: Item, PurchaseOrder, SalesOrder, SerialNo, Workflow
🧩 The list is continuously expanding as new globals and patterns are added.
These instructions will help you set up the package in a TypeScript project.
Make sure your project is configured for TypeScript:
npm install typescript
npx tsc --initInstall as a dev dependency:
# npm
npm install --save-dev @anygridtech/frappe-types
# yarn
yarn add --dev @anygridtech/frappe-types
# pnpm
pnpm add -D @anygridtech/frappe-typesThis package is designed to work with @anygridtech/frappe-ts-tools. You must set up frappe-ts-tools first:
👉 Follow @anygridtech/frappe-ts-tools Setup Instructions
The frappe-ts-tools package handles all TypeScript compilation and build configuration automatically.
After setup, you can use Frappe globals with full TypeScript support:
frappe.call({
method: "frappe.client.get",
args: {
doctype: "Customer",
name: "CUST-0001"
},
callback(r) {
console.log(r.message);
}
});This is a type-only package. Just include it in your dev dependencies — no runtime deployment required.
This project is a community effort.
Contributions are welcome! Open an issue or PR if you find missing or incorrect types.
- @anygridtech – Maintainers
- Inspired by @kylelobo – Initial template
- Frappe community for documentation and examples
- Inspiration from open-source type definition projects