@@ -57,18 +57,19 @@ export interface RequireAndTranspileModuleOptions
5757
5858export type StringMap = Map < string , string > ;
5959
60- export interface TransformOptions < OptionType = unknown >
60+ export interface TransformOptions < TransformerConfig = unknown >
6161 extends ReducedTransformOptions {
62- /** a cached file system which is used in jest-runtime - useful to improve performance */
62+ /** Cached file system which is used by ` jest-runtime` to improve performance. */
6363 cacheFS : StringMap ;
64+ /** Jest configuration of currently running project. */
6465 config : Config . ProjectConfig ;
65- /** A stringified version of the configuration - useful in cache busting */
66+ /** Stringified version of the `config` - useful in cache busting. */
6667 configString : string ;
67- /** the options passed through Jest's config by the user */
68- transformerConfig : OptionType ;
68+ /** Transformer configuration passed through `transform` option by the user. */
69+ transformerConfig : TransformerConfig ;
6970}
7071
71- export interface SyncTransformer < OptionType = unknown > {
72+ export interface SyncTransformer < TransformerConfig = unknown > {
7273 /**
7374 * Indicates if the transformer is capable of instrumenting the code for code coverage.
7475 *
@@ -80,29 +81,29 @@ export interface SyncTransformer<OptionType = unknown> {
8081 getCacheKey ?: (
8182 sourceText : string ,
8283 sourcePath : string ,
83- options : TransformOptions < OptionType > ,
84+ options : TransformOptions < TransformerConfig > ,
8485 ) => string ;
8586
8687 getCacheKeyAsync ?: (
8788 sourceText : string ,
8889 sourcePath : string ,
89- options : TransformOptions < OptionType > ,
90+ options : TransformOptions < TransformerConfig > ,
9091 ) => Promise < string > ;
9192
9293 process : (
9394 sourceText : string ,
9495 sourcePath : string ,
95- options : TransformOptions < OptionType > ,
96+ options : TransformOptions < TransformerConfig > ,
9697 ) => TransformedSource ;
9798
9899 processAsync ?: (
99100 sourceText : string ,
100101 sourcePath : string ,
101- options : TransformOptions < OptionType > ,
102+ options : TransformOptions < TransformerConfig > ,
102103 ) => Promise < TransformedSource > ;
103104}
104105
105- export interface AsyncTransformer < OptionType = unknown > {
106+ export interface AsyncTransformer < TransformerConfig = unknown > {
106107 /**
107108 * Indicates if the transformer is capable of instrumenting the code for code coverage.
108109 *
@@ -114,25 +115,25 @@ export interface AsyncTransformer<OptionType = unknown> {
114115 getCacheKey ?: (
115116 sourceText : string ,
116117 sourcePath : string ,
117- options : TransformOptions < OptionType > ,
118+ options : TransformOptions < TransformerConfig > ,
118119 ) => string ;
119120
120121 getCacheKeyAsync ?: (
121122 sourceText : string ,
122123 sourcePath : string ,
123- options : TransformOptions < OptionType > ,
124+ options : TransformOptions < TransformerConfig > ,
124125 ) => Promise < string > ;
125126
126127 process ?: (
127128 sourceText : string ,
128129 sourcePath : string ,
129- options : TransformOptions < OptionType > ,
130+ options : TransformOptions < TransformerConfig > ,
130131 ) => TransformedSource ;
131132
132133 processAsync : (
133134 sourceText : string ,
134135 sourcePath : string ,
135- options : TransformOptions < OptionType > ,
136+ options : TransformOptions < TransformerConfig > ,
136137 ) => Promise < TransformedSource > ;
137138}
138139
@@ -144,14 +145,14 @@ export interface AsyncTransformer<OptionType = unknown> {
144145 *
145146 * For more info on the sync vs async model, see https://jestjs.io/docs/code-transformation#writing-custom-transformers
146147 */
147- export type Transformer < OptionType = unknown > =
148- | SyncTransformer < OptionType >
149- | AsyncTransformer < OptionType > ;
148+ export type Transformer < TransformerConfig = unknown > =
149+ | SyncTransformer < TransformerConfig >
150+ | AsyncTransformer < TransformerConfig > ;
150151
151152export type TransformerCreator <
152- X extends Transformer < OptionType > ,
153- OptionType = unknown ,
154- > = ( options ?: OptionType ) => X ;
153+ X extends Transformer < TransformerConfig > ,
154+ TransformerConfig = unknown ,
155+ > = ( transformerConfig ?: TransformerConfig ) => X ;
155156
156157/**
157158 * Instead of having your custom transformer implement the Transformer interface
0 commit comments