Last active
July 16, 2023 15:44
-
-
Save gtrabanco/fbe450def75ee71232b904a56ce85139 to your computer and use it in GitHub Desktop.
Snippets for typescript VSCode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"zschema": { | |
"prefix": "zschema", | |
"body": [ | |
"export const $1Schema = z.$2($3);", | |
"export type ${1/(.*)/${1:/pascalcase}/} = z.infer<typeof $1Schema>;", | |
"", | |
"$0" | |
], | |
"description": "Creates a function wrapper for a model's attribute." | |
}, | |
"zfile": { | |
"prefix": "zfile", | |
"body": [ | |
"import { z } from 'zod';", | |
"", | |
"const schemaObject = {", | |
" $1", | |
"};", | |
"", | |
"export const ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g} = z.$2(schemaObject);", | |
"export type ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g} = z.infer<typeof ${TM_FILENAME_BASE/(.*)/${1:/camelcase}/g}>;", | |
"", | |
"$0" | |
], | |
"description": "Creates a function wrapper for a model's attribute using zod." | |
}, | |
"zfileschema": { | |
"prefix": "zfile", | |
"body": [ | |
"import { z } from 'zod';", | |
"", | |
"const schemaObject = {", | |
" $1", | |
"};", | |
"", | |
"export const ${TM_FILENAME_BASE/(.*)/${1:/camelcase}/g}Schema = z.$2(schemaObject);", | |
"export type ${TM_FILENAME_BASE/(.*)/${1:/pascalcase}/g} = z.infer<typeof ${TM_FILENAME_BASE/(.*)/${1:/camelcase}/g}Schema>;", | |
"", | |
"$0" | |
], | |
"description": "Creates a function wrapper for a model's attribute using zod." | |
}, | |
"zschema-attr": { | |
"prefix": "zschema-attr", | |
"body": [ | |
"$1: z.$2()," | |
], | |
"description": "Creates a model's attribute using zod." | |
}, | |
"zschema-attr-optional": { | |
"prefix": "zschema-attr-optional", | |
"body": [ | |
"$1: z.$2().optional()," | |
], | |
"description": "Creates an ooptional attribute using zod." | |
}, | |
"from": { | |
"prefix": "from", | |
"body": [ | |
"import $2 from '$1';", | |
"$0" | |
], | |
"description": "Import statement" | |
}, | |
"from-as": { | |
"prefix": "from-as", | |
"body": [ | |
"import { $2 as $3 } from '$1';", | |
"$0" | |
], | |
"description": "Import statement" | |
}, | |
"from-all": { | |
"prefix": "from-all", | |
"body": [ | |
"import * as $2 from '$1';", | |
"$0" | |
], | |
"description": "Import statement" | |
}, | |
"fn": { | |
"prefix": "fn", | |
"body": [ | |
"function $1($2)$3 {", | |
" $4", | |
"};", | |
"", | |
"$0" | |
], | |
"description": "Function" | |
}, | |
"afn": { | |
"prefix": "afn", | |
"body": [ | |
"async function $1($2)$3 {", | |
" $4", | |
"};", | |
"", | |
"$0" | |
], | |
"description": "Async function" | |
}, | |
"efn": { | |
"prefix": "fn", | |
"body": [ | |
"export function $1($2)$3 {", | |
" $4", | |
"};", | |
"", | |
"$0" | |
], | |
"description": "Export function" | |
}, | |
"eafn": { | |
"prefix": "afn", | |
"body": [ | |
"export async function $1($2)$3 {", | |
" $4", | |
"};", | |
"", | |
"$0" | |
], | |
"description": "Export async function" | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment