Advertisement
ItsMeStevieG

ts-snippets.json

Feb 23rd, 2021
932
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 8.45 KB | None | 0 0
  1. {
  2.   "typeScriptReactClassComponent": {
  3.     "prefix": "tsrcc",
  4.     "body": [
  5.       "import React, { Component } from 'react'",
  6.       "",
  7.       "interface Props {",
  8.       "\t",
  9.       "}",
  10.       "interface State {",
  11.       "\t",
  12.       "}",
  13.       "",
  14.       "export default class ${1:${TM_FILENAME_BASE}} extends Component<Props, State> {",
  15.       "\tstate = {}",
  16.       "",
  17.       "\trender() {",
  18.       "\t\treturn (",
  19.       "\t\t\t<div>",
  20.       "\t\t\t\t$0",
  21.       "\t\t\t</div>",
  22.       "\t\t)",
  23.       "\t}",
  24.       "}",
  25.       ""
  26.     ],
  27.     "description": "Creates a React component class with ES7 module system and TypeScript interfaces"
  28.   },
  29.   "typeScriptReactClassExportComponent": {
  30.     "prefix": "tsrce",
  31.     "body": [
  32.       "import React, { Component } from 'react'",
  33.       "",
  34.       "interface Props {",
  35.       "\t",
  36.       "}",
  37.       "interface State {",
  38.       "\t",
  39.       "}",
  40.       "",
  41.       "class ${1:${TM_FILENAME_BASE}} extends Component<Props, State> {",
  42.       "\tstate = {}",
  43.       "",
  44.       "\trender() {",
  45.       "\t\treturn (",
  46.       "\t\t\t<div>",
  47.       "\t\t\t\t$0",
  48.       "\t\t\t</div>",
  49.       "\t\t)",
  50.       "\t}",
  51.       "}",
  52.       "",
  53.       "export default ${1:${TM_FILENAME_BASE}}",
  54.       ""
  55.     ],
  56.     "description": "Creates a React component class with ES7 module system and TypeScript interfaces"
  57.   },
  58.   "typeScriptReactFunctionalExportComponent": {
  59.     "prefix": "tsrfce",
  60.     "body": [
  61.       "import React, { ReactElement } from 'react'",
  62.       "",
  63.       "interface Props {",
  64.       "\t",
  65.       "}",
  66.       "",
  67.       "function ${1:${TM_FILENAME_BASE}}({}: Props): ReactElement {",
  68.       "\treturn (",
  69.       "\t\t<div>",
  70.       "\t\t\t$0",
  71.       "\t\t</div>",
  72.       "\t)",
  73.       "}",
  74.       "",
  75.       "export default ${1:${TM_FILENAME_BASE}}",
  76.       ""
  77.     ],
  78.     "description": "Creates a React Functional Component with ES7 module system and TypeScript interface"
  79.   },
  80.   "typeScriptReactFunctionalComponent": {
  81.     "prefix": "tsrfc",
  82.     "body": [
  83.       "import React, { ReactElement } from 'react'",
  84.       "",
  85.       "interface Props {",
  86.       "\t",
  87.       "}",
  88.       "",
  89.       "export default function ${1:${TM_FILENAME_BASE}}({}: Props): ReactElement {",
  90.       "\treturn (",
  91.       "\t\t<div>",
  92.       "\t\t\t$0",
  93.       "\t\t</div>",
  94.       "\t)",
  95.       "}",
  96.       ""
  97.     ],
  98.     "description": "Creates a React Functional Component with ES7 module system and TypeScript interface"
  99.   },
  100.   "typeScriptReactArrowFunctionExportComponent": {
  101.     "prefix": "tsrafce",
  102.     "body": [
  103.       "import React from 'react'",
  104.       "",
  105.       "interface Props {",
  106.       "\t",
  107.       "}",
  108.       "",
  109.       "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {",
  110.       "\treturn (",
  111.       "\t\t<div>",
  112.       "\t\t\t$0",
  113.       "\t\t</div>",
  114.       "\t)",
  115.       "}",
  116.       "",
  117.       "export default ${1:${TM_FILENAME_BASE}}",
  118.       ""
  119.     ],
  120.     "description": "Creates a React Arrow Function Component with ES7 module system and TypeScript interface"
  121.   },
  122.   "typeScriptReactArrowFunctionComponent": {
  123.     "prefix": "tsrafc",
  124.     "body": [
  125.       "import React from 'react'",
  126.       "",
  127.       "interface Props {",
  128.       "\t",
  129.       "}",
  130.       "",
  131.       "export const ${1:${TM_FILENAME_BASE}} = (props: Props) => {",
  132.       "\treturn (",
  133.       "\t\t<div>",
  134.       "\t\t\t$0",
  135.       "\t\t</div>",
  136.       "\t)",
  137.       "}",
  138.       ""
  139.     ],
  140.     "description": "Creates a React Arrow Function Component with ES7 module system and TypeScript interface"
  141.   },
  142.   "typeScriptReactClassPureComponent": {
  143.     "prefix": "tsrpc",
  144.     "body": [
  145.       "import React, { PureComponent } from 'react'",
  146.       "",
  147.       "interface Props {",
  148.       "\t",
  149.       "}",
  150.       "",
  151.       "export default class ${1:${TM_FILENAME_BASE}} extends PureComponent<Props> {",
  152.       "\trender() {",
  153.       "\t\treturn (",
  154.       "\t\t\t<div>",
  155.       "\t\t\t\t$0",
  156.       "\t\t\t</div>",
  157.       "\t\t)",
  158.       "\t}",
  159.       "}",
  160.       ""
  161.     ],
  162.     "description": "Creates a React pure component class with ES7 module system and TypeScript interface"
  163.   },
  164.   "typeScriptReactClassExportPureComponent": {
  165.     "prefix": "tsrpce",
  166.     "body": [
  167.       "import React, { PureComponent } from 'react'",
  168.       "",
  169.       "interface Props {",
  170.       "\t",
  171.       "}",
  172.       "",
  173.       "class ${1:${TM_FILENAME_BASE}} extends PureComponent<Props> {",
  174.       "\trender() {",
  175.       "\t\treturn (",
  176.       "\t\t\t<div>",
  177.       "\t\t\t\t$0",
  178.       "\t\t\t</div>",
  179.       "\t\t)",
  180.       "\t}",
  181.       "}",
  182.       "",
  183.       "export default ${1:${TM_FILENAME_BASE}}",
  184.       ""
  185.     ],
  186.     "description": "Creates a React pure component class with ES7 module system and TypeScript interface"
  187.   },
  188.   "typeScriptReactFunctionMemoComponent": {
  189.     "prefix": "tsrmc",
  190.     "body": [
  191.       "import React, { memo } from 'react'",
  192.       "",
  193.       "interface Props {",
  194.       "\t",
  195.       "}",
  196.       "",
  197.       "export default memo(function ${1:${TM_FILENAME_BASE}}({}: Props) {",
  198.       "\treturn (",
  199.       "\t\t<div>",
  200.       "\t\t\t$0",
  201.       "\t\t</div>",
  202.       "\t)",
  203.       "})",
  204.       ""
  205.     ],
  206.     "description": "Creates a React Memo Function Component with ES7 module system and TypeScript interface"
  207.   },
  208.   "typeScriptReactClassCompomentRedux": {
  209.     "prefix": "tsrcredux",
  210.     "body": [
  211.       "import React, { Component } from 'react'",
  212.       "import { connect } from 'react-redux'",
  213.       "",
  214.       "interface Props {",
  215.       "\t",
  216.       "}",
  217.       "interface State {",
  218.       "\t",
  219.       "}",
  220.       "",
  221.       "export class ${1:${TM_FILENAME_BASE}} extends Component<Props, State> {",
  222.       "\tstate = {}",
  223.       "",
  224.       "\trender() {",
  225.       "\t\treturn (",
  226.       "\t\t\t<div>",
  227.       "\t\t\t\t$0",
  228.       "\t\t\t</div>",
  229.       "\t\t)",
  230.       "\t}",
  231.       "}",
  232.       "",
  233.       "const mapStateToProps = (state) => ({",
  234.       "\t",
  235.       "})",
  236.       "",
  237.       "const mapDispatchToProps = {",
  238.       "\t",
  239.       "}",
  240.       "",
  241.       "export default connect(mapStateToProps, mapDispatchToProps)(${1:${TM_FILENAME_BASE}})",
  242.       ""
  243.     ],
  244.     "description": "Creates a React component class with PropTypes with connected redux and ES7 module system and TypeScript interfaces"
  245.   },
  246.   "typescriptReactNativeArrowFunctionComponent": {
  247.     "prefix": "tsrnf",
  248.     "body": [
  249.       "import React from 'react'",
  250.       "import { View, Text } from 'react-native'",
  251.       "",
  252.       "interface Props {",
  253.       "\t",
  254.       "}",
  255.       "",
  256.       "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {",
  257.       "\treturn (",
  258.       "\t\t<View>",
  259.       "\t\t\t<Text>$0</Text>",
  260.       "\t\t</View>",
  261.       "\t)",
  262.       "}",
  263.       "",
  264.       "export default ${1:${TM_FILENAME_BASE}}",
  265.       ""
  266.     ],
  267.     "description": "Creates a React Native Arrow Function Component with ES7 module system and TypeScript interface"
  268.   },
  269.   "typescriptReactNativeArrowFunctionComponentNamedProps": {
  270.     "prefix": "tsrnfi",
  271.     "body": [
  272.       "import React from 'react'",
  273.       "import { View } from 'react-native'",
  274.       "",
  275.       "interface ${1:${TM_FILENAME_BASE}}Props {",
  276.       "\t",
  277.       "}",
  278.       "",
  279.       "const ${1:${TM_FILENAME_BASE}}: React.FunctionComponent<${1:${TM_FILENAME_BASE}}Props> = (props) => {",
  280.       "\treturn (",
  281.       "\t\t<View>",
  282.       "\t\t\t$0",
  283.       "\t\t</View>",
  284.       "\t)",
  285.       "}",
  286.       "",
  287.       "export default ${1:${TM_FILENAME_BASE}}",
  288.       ""
  289.     ],
  290.     "description": "Creates a React Native Arrow Function Component with ES7 module system and named TypeScript interface"
  291.   },
  292.   "typescriptReactNativeArrowFunctionComponentWithStyles": {
  293.     "prefix": "tsrnfs",
  294.     "body": [
  295.       "import React from 'react'",
  296.       "import { StyleSheet, Text, View } from 'react-native'",
  297.       "",
  298.       "interface Props {",
  299.       "\t",
  300.       "}",
  301.       "",
  302.       "const ${1:${TM_FILENAME_BASE}} = (props: Props) => {",
  303.       "\treturn (",
  304.       "\t\t<View>",
  305.       "\t\t\t<Text>$0</Text>",
  306.       "\t\t</View>",
  307.       "\t)",
  308.       "}",
  309.       "",
  310.       "export default ${1:${TM_FILENAME_BASE}}",
  311.       "",
  312.       "const styles = StyleSheet.create({})",
  313.       ""
  314.     ],
  315.     "description": "Creates a React Native Arrow Function Component with ES7 module system, TypeScript interface and StyleSheet"
  316.   },
  317.   "Export interface": {
  318.     "prefix": "expint",
  319.     "body": ["export interface ${1:${TM_FILENAME_BASE}} {$0}"]
  320.   },
  321.   "Export type": {
  322.     "prefix": "exptp",
  323.     "body": ["export type ${1:${TM_FILENAME_BASE}} = {$0}"]
  324.   }
  325. }
  326.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement