File tree 7 files changed +28
-11
lines changed
7 files changed +28
-11
lines changed Original file line number Diff line number Diff line change @@ -148,17 +148,10 @@ export const getResReqTypes = (
148
148
const isFormUrlEncoded =
149
149
formUrlEncodedContentTypes . includes ( contentType ) ;
150
150
151
- const imports = [
152
- ...resolvedValue . imports ,
153
- ...( resolvedValue . hasReadonlyProps
154
- ? [ { name : 'NonReadonly' } ]
155
- : [ ] ) ,
156
- ] ;
157
-
158
151
if ( ( ! isFormData && ! isFormUrlEncoded ) || ! propName ) {
159
152
return {
160
153
...resolvedValue ,
161
- imports,
154
+ imports : resolvedValue . imports ,
162
155
contentType,
163
156
} ;
164
157
}
@@ -182,7 +175,7 @@ export const getResReqTypes = (
182
175
183
176
return {
184
177
...resolvedValue ,
185
- imports,
178
+ imports : resolvedValue . imports ,
186
179
formData,
187
180
formUrlEncoded,
188
181
contentType,
Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ export const writeSchemas = async ({
130
130
. sort ( )
131
131
. join ( '\n' ) ;
132
132
133
- const fileContent = `${ header } \n${ exports } \n ${ getOrvalGeneratedTypes ( ) } ` ;
133
+ const fileContent = `${ header } \n${ exports } ` ;
134
134
135
135
await fs . writeFile ( schemaFilePath , fileContent ) ;
136
136
} catch ( e ) {
Original file line number Diff line number Diff line change 8
8
upath ,
9
9
} from '../utils' ;
10
10
import { generateTarget } from './target' ;
11
+ import { getOrvalGeneratedTypes } from './types' ;
11
12
12
13
export const writeSingleMode = async ( {
13
14
builder,
@@ -90,6 +91,11 @@ export const writeSingleMode = async ({
90
91
data += generateMutatorImports ( { mutators : formUrlEncoded } ) ;
91
92
}
92
93
94
+ if ( implementation . includes ( 'NonReadonly<' ) ) {
95
+ data += getOrvalGeneratedTypes ( ) ;
96
+ data += '\n' ;
97
+ }
98
+
93
99
if ( ! output . schemas && needSchema ) {
94
100
data += generateModelsInline ( builder . schemas ) ;
95
101
}
Original file line number Diff line number Diff line change 8
8
upath ,
9
9
} from '../utils' ;
10
10
import { generateTarget } from './target' ;
11
+ import { getOrvalGeneratedTypes } from './types' ;
11
12
12
13
export const writeSplitMode = async ( {
13
14
builder,
@@ -102,6 +103,10 @@ export const writeSplitMode = async ({
102
103
} ) ;
103
104
}
104
105
106
+ if ( implementation . includes ( 'NonReadonly<' ) ) {
107
+ implementationData += getOrvalGeneratedTypes ( ) ;
108
+ }
109
+
105
110
implementationData += `\n${ implementation } ` ;
106
111
mswData += `\n${ implementationMSW } ` ;
107
112
Original file line number Diff line number Diff line change 8
8
upath ,
9
9
} from '../utils' ;
10
10
import { generateTargetForTags } from './target-tags' ;
11
+ import { getOrvalGeneratedTypes } from './types' ;
11
12
12
13
export const writeSplitTagsMode = async ( {
13
14
builder,
@@ -109,6 +110,11 @@ export const writeSplitTagsMode = async ({
109
110
} ) ;
110
111
}
111
112
113
+ if ( implementation . includes ( 'NonReadonly<' ) ) {
114
+ implementationData += getOrvalGeneratedTypes ( ) ;
115
+ implementationData += '\n' ;
116
+ }
117
+
112
118
implementationData += `\n${ implementation } ` ;
113
119
mswData += `\n${ implementationMSW } ` ;
114
120
Original file line number Diff line number Diff line change 9
9
upath ,
10
10
} from '../utils' ;
11
11
import { generateTargetForTags } from './target-tags' ;
12
+ import { getOrvalGeneratedTypes } from './types' ;
12
13
13
14
export const writeTagsMode = async ( {
14
15
builder,
@@ -104,6 +105,12 @@ export const writeTagsMode = async ({
104
105
}
105
106
106
107
data += '\n\n' ;
108
+
109
+ if ( implementation . includes ( 'NonReadonly<' ) ) {
110
+ data += getOrvalGeneratedTypes ( ) ;
111
+ data += '\n' ;
112
+ }
113
+
107
114
data += implementation ;
108
115
109
116
if ( output . mock ) {
Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ type UnionToIntersection<U> =
19
19
type DistributeReadOnlyOverUnions<T> = T extends any ? NonReadonly<T> : never;
20
20
21
21
type Writable<T> = Pick<T, WritableKeys<T>>;
22
- export type NonReadonly<T> = [T] extends [UnionToIntersection<T>] ? {
22
+ type NonReadonly<T> = [T] extends [UnionToIntersection<T>] ? {
23
23
[P in keyof Writable<T>]: T[P] extends object
24
24
? NonReadonly<NonNullable<T[P]>>
25
25
: T[P];
You can’t perform that action at this time.
1 commit comments
vercel[bot] commentedon Apr 11, 2023
Successfully deployed to the following URLs:
orval – ./
orval-anymaniax.vercel.app
orval-git-master-anymaniax.vercel.app
orval.vercel.app
www.orval.dev
orval.dev