Created
July 23, 2021 23:38
-
-
Save mwafa/73116dbce5b5398ef9dee9d07c37ef25 to your computer and use it in GitHub Desktop.
Typescript dan Typescript-React User Snippet for Vscode
This file contains hidden or 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
| { | |
| "Create Next Api": { | |
| "prefix": "nextapi", | |
| "body": [ | |
| "import { NextApiRequest, NextApiResponse } from \"next\"", | |
| "export default async (req: NextApiRequest, res: NextApiResponse) => {", | |
| " try {", | |
| " switch (req.method) {", | |
| " default:", | |
| " throw new Error()", | |
| " }", | |
| " } catch (e) {", | |
| " const code = e.code || 500", | |
| " const message = e.code ? e.message : \"Something error!\"", | |
| " return res.status(code).json({", | |
| " error: true,", | |
| " message,", | |
| " })", | |
| " }", | |
| " }" | |
| ], | |
| "description": "Create api element" | |
| }, | |
| } |
This file contains hidden or 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
| { | |
| "Create Element and Interface": { | |
| "prefix": "nextcomponent", | |
| "body": [ | |
| "type ${1:$TM_FILENAME_BASE}Props = {}", | |
| "", | |
| "const ${1:$TM_FILENAME_BASE}: React.FC<${1:$TM_FILENAME_BASE}Props> = ({...props}) => {", | |
| "", | |
| " return ${0}", | |
| "}", | |
| "", | |
| "${1:$TM_FILENAME_BASE}.defaultProps = {}", | |
| "", | |
| "export default ${1:$TM_FILENAME_BASE}" | |
| ], | |
| "description": "Create element and interface" | |
| }, | |
| "Create Element": { | |
| "prefix": "nextsimplecomponent", | |
| "body": [ | |
| "const ${1:$TM_FILENAME_BASE}: React.FC = () => {", | |
| "", | |
| " return ${0}", | |
| "}", | |
| "", | |
| "export default ${1:$TM_FILENAME_BASE}" | |
| ], | |
| "description": "Create element and interface" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment