Skip to main content

Type Safety

PromptDX supports full type-safety, with just a few short steps.

Type Safety

Ading Type Safety

Adjust your tsconfig

Note: It is recommended to use a separate tsconfig.json file for your PromptDX files.

{
"compilerOptions": {
...,
"allowJs": true
},
"mdx": {
"checkMdx": true
}
}

Add JSDOC types to define props for your promptdx files

{/**
* @typedef Props
* @property {string} name - Who to greet.
*/
}

# Hello {props.name}

Add types for your filters/tags

Create a types/global.d.ts file and define your own custom filters/tags.

import type { BaseMDXProvidedComponents, FilterFunction } from '@puzzlet/promptdx';

declare global {
const myCustomFilter: FilterFunction<string, string>;

interface MDXProvidedComponents extends BaseMDXProvidedComponents {
MyCustomTag: React.FC<MyCustomTagProps>;
}
}
export {};