File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
ui/frontend/reducers/output Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change 11import { createAsyncThunk , createSlice } from '@reduxjs/toolkit' ;
2+ import * as z from 'zod' ;
23
34import { adaptFetchError , jsonPost , routes } from '../../actions' ;
45import { formatRequestSelector } from '../../selectors' ;
@@ -21,19 +22,22 @@ interface FormatRequestBody {
2122 edition : string ;
2223}
2324
24- interface FormatResponseBody {
25- success : boolean ;
26- code : string ;
27- stdout : string ;
28- stderr : string ;
29- }
25+ const FormatResponseBody = z . object ( {
26+ success : z . boolean ( ) ,
27+ code : z . string ( ) ,
28+ stdout : z . string ( ) ,
29+ stderr : z . string ( ) ,
30+ } ) ;
31+
32+ type FormatResponseBody = z . infer < typeof FormatResponseBody > ;
3033
3134export const performFormat = createAsyncThunk < FormatResponseBody , void , { state : RootState } > (
3235 sliceName ,
3336 async ( _arg : void , { getState } ) => {
3437 const body : FormatRequestBody = formatRequestSelector ( getState ( ) ) ;
3538
36- return adaptFetchError ( ( ) => jsonPost < FormatResponseBody > ( routes . format , body ) ) ;
39+ const d = await adaptFetchError ( ( ) => jsonPost ( routes . format , body ) ) ;
40+ return FormatResponseBody . parseAsync ( d ) ;
3741 } ,
3842) ;
3943
You can’t perform that action at this time.
0 commit comments