Comprehensive TypeScript type definitions for the Jest testing framework ecosystem providing shared types for configuration, test results, transforms, and global utilities.
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Types for Jest's code transformation system enabling custom transformers and build tool integration. These types are designed to avoid huge dependency trees while providing the necessary interfaces for code transformation.
Core interface for the result of code transformation operations.
/**
* Result of code transformation
* Designed to avoid huge dependency trees for transformation processing
*/
interface TransformResult {
/** Transformed code output */
code: string;
/** Original source code before transformation */
originalCode: string;
/** Path to source map file, or null if no source map */
sourceMapPath: string | null;
}Usage Examples:
import type { TransformTypes } from "@jest/types";
// Custom transformer function signature
type CustomTransformer = (
source: string,
filename: string,
options?: any
) => TransformTypes.TransformResult;
// Example transformer implementation
const myTransformer: CustomTransformer = (source, filename, options) => {
// Perform transformation logic
const transformedCode = transformSource(source, options);
return {
code: transformedCode,
originalCode: source,
sourceMapPath: `${filename}.map`,
};
};
// Process transform result
const processTransformResult = (result: TransformTypes.TransformResult) => {
console.log('Transformed code length:', result.code.length);
console.log('Original code length:', result.originalCode.length);
if (result.sourceMapPath) {
console.log('Source map available at:', result.sourceMapPath);
}
};
// Check if transformation changed the code
const isCodeTransformed = (result: TransformTypes.TransformResult): boolean => {
return result.code !== result.originalCode;
};