Custom chain methods
Last updated: 2026-06-18
Use this page when you want to add a method to an existing builder:
This is different from a custom DSL type and different from an s.xxx() factory.
Add the runtime builder method
registerExtension() can register a DSL literal and a namespace factory, but it does not automatically add a method to DslBuilder.prototype. Provide the runtime method in your extension setup:
The method should be idempotent so hot reload, repeated test setup, or plugin reinstall does not keep replacing it.
Add TypeScript builder hints
Now s('string!').tenantId() has builder method hints.
Add direct String-chain hints
Only add this when your project explicitly uses direct String-chain source code:
Direct String-chain code still needs one of these runtime paths:
- compile-time transform with
schema-dsl/transformorschema-dsl/esbuild; - explicit String extension installation through
schema-dsl/register-string; - the compatibility/root entry when you intentionally accept the v1 String extension behavior.
Configure transform for custom methods
When transforming direct String-chain source, add the method name:
When the chain starts from a custom DSL literal, also allow that literal:
Recommended package shape
For reusable extensions, keep runtime implementation and type declarations together:
The implementation installs the builder method. The declaration file augments schema-dsl/pure and, only when needed, schema-dsl/string-types. The transform config exports additionalMethods and additionalTypes for your build tool.
Corresponding sample file
Example entry: custom-chain-methods.ts Note: Installs a custom builder method, validates the builder path, and verifies transform configuration for direct String-chain source.