Kind: Type
Source: src/middleware/language/language.ts
Part of: Middleware
Type-safe detector map
Detectors defines the type-safe map of language detector entries used by the language middleware. It keeps detector registration aligned with the detector contract expected by the middleware.
Definition
tsRecord<keyof typeof detectors, DetectorFunction>
Diagram
mermaidgraph LR Middleware[Language middleware] --> Detectors[Detectors map] Detectors --> Detector[Detector entry] Detector --> Result[Detected language result]
Usage
tsimport type { Detectors } from './middleware/language/language';
const detectors: Detectors = {
// Add detector entries that match the detector contract.
};
export function getDetectors(): Detectors {
return detectors;
}
AI Coding Instructions
- Keep detector map entries compatible with the detector type defined in
language.ts. - Import
Detectorswithimport typewhen it is only used for type checking. - Add new detector registrations through the typed map instead of bypassing type checks with casts.
- Update middleware configuration when changing the detector map or detector registration flow.
Was this page helpful?