@@ -45,11 +45,8 @@ export async function transformTypia(
45
45
46
46
const { program, tsSource } = await getProgramAndSource ( id , source , compilerOptions , cacheEnable ) ;
47
47
48
- const {
49
- diagnostics,
50
- transformed,
51
- file,
52
- } = transform ( id , program , tsSource , options . typia ) ;
48
+ using result = transform ( id , program , tsSource , options . typia ) ;
49
+ const { diagnostics, transformed, file } = result ;
53
50
54
51
warnDiagnostic ( diagnostics , transformed , unpluginContext ) ;
55
52
@@ -145,12 +142,14 @@ function transform(
145
142
tsSource : ts . SourceFile ,
146
143
typiaOptions ?: ResolvedOptions [ 'typia' ] ,
147
144
) : {
148
- /** The diagnostics */
145
+ /** The diagnostics */
149
146
diagnostics : ts . Diagnostic [ ] ;
150
147
/** The transformed source files */
151
148
transformed : ts . SourceFile [ ] ;
152
149
/** The transformed source file we need */
153
150
file : ts . SourceFile ;
151
+ /** Dispose the transformation */
152
+ [ Symbol . dispose ] : ( ) => void ;
154
153
} {
155
154
const diagnostics : ts . Diagnostic [ ] = [ ] ;
156
155
@@ -179,12 +178,14 @@ function transform(
179
178
throw new Error ( 'No file found' ) ;
180
179
}
181
180
182
- /** dispose transformation result */
183
- transformationResult . dispose ( ) ;
184
-
185
181
const { transformed } = transformationResult ;
186
182
187
- return { diagnostics, transformed, file } ;
183
+ return {
184
+ diagnostics,
185
+ transformed,
186
+ file,
187
+ [ Symbol . dispose ] : ( ) => transformationResult . dispose ( ) ,
188
+ } ;
188
189
}
189
190
190
191
/** Warn diagnostics */
0 commit comments