File tree 1 file changed +32
-0
lines changed
1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -316,3 +316,35 @@ Logs a warning to the console if `input` isn't the correct type.
316
316
### ` toString(): string `
317
317
318
318
Returns a string representation of this type (using TS type syntax in most cases).
319
+
320
+ ## ` t.ExtractType<T extends Type<any>> `
321
+
322
+ Gets the TypeScript type that a validator type accepts. For example:
323
+
324
+ ``` ts
325
+ import * as t from ' typescript-validators'
326
+
327
+ const PostValidator = t .simpleObject ({
328
+ author: t .simpleObject ({
329
+ name: t .string (),
330
+ username: t .string (),
331
+ }),
332
+ content: t .string (),
333
+ tags: t .array (t .string ()),
334
+ })
335
+
336
+ type Post = t .ExtractType <typeof PostValidator >
337
+ ` ` `
338
+
339
+ Hover over ` Post ` in the IDE and you'll see, voilà:
340
+
341
+ ` ` ` ts
342
+ type Post = {
343
+ author: {
344
+ name: string
345
+ username: string
346
+ }
347
+ content: string
348
+ tags: string []
349
+ }
350
+ ` ` `
You can’t perform that action at this time.
0 commit comments