Warning
This is an internal project, and is not intended for public use. No support or stability guarantees are provided.
A function for parsing types.md files back into structured type metadata. This is the reverse operation of syncTypes — it reads markdown and reconstructs organized type exports.
loadServerTypesText parses a types.md file that was previously generated by syncTypes. It reconstructs:
Both loadServerTypesText and loadServerTypesMeta extend OrganizeTypesResult<TypesMeta> and share the same core fields (exports, additionalTypes, externalTypes, typeNameMap, allDependencies). This shared shape (TypesSourceData) is the contract consumed by loadServerTypes, which accepts either function's output and applies highlighting on top.
This is useful for:
import { loadServerTypesText } from '@mui/internal-docs-infra/pipeline/loadServerTypesText';
// Load types from a file URL
const result = await loadServerTypesText('file:///absolute/path/to/types.md');
// Access the parsed types
result.exports; // Record<string, { type: TypesMeta; additionalTypes: TypesMeta[] }>
result.additionalTypes; // TypesMeta[] — top-level non-namespaced types
result.externalTypes; // Record<string, string> — external type definitions
result.variantTypeNames; // Record<string, string[]> — variant → type names
result.typeNameMap; // Record<string, string> — flat name → dotted name
result.allDependencies; // string[] — file paths to watch
The parser expects markdown in the format generated by syncTypes:
Each type is defined by an H3 heading (###) followed by optional description and tables:
### ComponentName
Optional description paragraph.
**ComponentName Props:**
| Prop | Type | Default | Description |
| ---------- | --------- | ----------- | ------------------------------ |
| propName | `string` | `"default"` | Prop description |
| required\* | `boolean` | - | Required prop (marked with \*) |
The parser determines type kind based on content:
rawuse → hookcomponentfunctionrawcomponentThe parser recognizes these table formats, identified by bold headings like **Name Props:**:
| Prop | Type | Default | Description | (4 columns)| Parameter | Type | Default | Description | (4 columns)| Attribute | Type | Description | (3 columns)| Variable | Type | Description | (3 columns)| Property | Type | Description | (3 columns), or a code blockAdditionally, the parser recognizes:
**`propName` Prop Example:** followed by a code block**`propName` Prop References:** followed by a bullet listExternal types are parsed from the ## External Types H2 section. Each type uses an H4 heading (####) with a code block:
## External Types
#### TypeName
\`\`\`typescript
type TypeName = string | number;
\`\`\`
Variant and type name mapping metadata is stored in dedicated H2 sections:
Export Groups lists which types belong to each variant:
## Export Groups
- `Default`: `Button`, `ButtonProps`
- `Shared`
Canonical Types maps flat names to canonical dotted names, optionally scoped to variants:
## Canonical Types
- `Accordion.Trigger` (`Default`): `AccordionTrigger`
- `Accordion.Root`: `AccordionRoot`
Load and parse a types.md file into TypesMeta[].
| Parameter | Type | Description |
|---|---|---|
| fileUrl | | file:// URL to the types.md file |
| ordering | |
Promise<TypesSourceData>Parsed types and external types
Common data returned by both syncTypes and loadServerTypesText. This is the shared contract consumed by loadServerTypes.
type TypesSourceData = {
/** External types discovered in the file */
externalTypes: Record<string, string>;
/**
* Type name map (merged across all variants).
* Maps flat names (like "AccordionTriggerState") to dotted names (like "Accordion.Trigger.State").
*/
typeNameMap: Record<string, string>;
/** All dependencies that should be watched for changes */
allDependencies: string[];
/** Whether the types.md file was updated (false if loaded from existing file) */
updated: boolean;
/** Export data where each export has a main type and related additional types */
exports: Record<string, { type: TypesMeta; additionalTypes: TypesMeta[] }>;
/** Top-level non-namespaced types not claimed by any variant-only group */
additionalTypes: TypesMeta[];
/**
* Types belonging to variant-only groups (variants with no main export).
* Keyed by variant name, each entry contains the types from that variant.
* These are separated from `additionalTypes` to avoid duplication.
*/
variantOnlyAdditionalTypes: Record<string, TypesMeta[]>;
/**
* Maps variant names to the type names that originated from that variant.
* Used for namespace imports (e.g., `* as Types`) to filter additionalTypes
* to only show types from that specific module.
*/
variantTypeNames: Record<string, string[]>;
/**
* Maps variant names to their per-variant typeNameMaps.
* Used for Canonical Types annotations showing which variants contain each type.
*/
variantTypeNameMaps: Record<string, Record<string, string>>;
}syncTypes - Generates the types.md files that this function parsesloadServerTypes - Calls this function (when sync: false) or syncTypes, then applies highlighting