Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

VS Code Const & Props snippets for JS and TS

License

NotificationsYou must be signed in to change notification settings

deinsoftware/vscode-const-props-snippets

Repository files navigation

VersionInstallsRatingslicenseOpen in VS Code

Const & Props

The quick and easy way to create and use Const & Props withVS Code.

We alsorecommend installing his complement extensionsArrow Function Snippets andDebug

Menu


Installation

Quick Launch

Open the quick launch withctrl+shift+P (Win/Linux) orcmd+shift+P (macOS).

Paste the following command and pressEnter:

ext install deinsoftware.const-props-snippets

Extension Manager

Open the extension manager withctrl+shift+X (Win/Linux) orcmd+shift+X (macOS), search forConst & Props Snippets and click on[Install] button.

Marketplace

Const & Props Snippets

Back to menu


Supported Languages

LanguageExtension
JavaScript.js
TypeScript.ts
JavaScript React.jsx
TypeScript React.tsx
Vue.vue
JSON.json
JSONC.jsonc
JSON5.json5

Back to menu


Snippets

Below is a list of all available snippets and the triggers of each one. The means theTAB jump position and the final cursor position.

Variables

TriggerDescriptionResult JSResult TS
cv→const variableconst ░name = █const ░name = █
cvt→const variable typeconst ░name: ░type = █
cvm→const variable multiple typeconst ░name: (░type | ░type) = █
cs→const stringconst ░name = '░'█const ░name: string = '░'█
ctl→const template literalsconst ░name = `░${░expression}░`█const ░name: string = `░${░expression}░`█
cn→const numberconst ░name = ░0█const ░name: number = ░0█
cb→const booleanconst ░name = ░true█const ░name: boolean = ░true█
co→const objectconst ░name = {░}█const ░name = {░}█
co→const object freezeconst ░name = Object.freeze({░})█const ░name = Object.freeze({░})█
coi→const object interfaceconst ░name: Interface = {░}█
ca→const arrayconst ░name = [░]█const ░name = [░]█
cat→const array typeconst ░name: type = [░]█
cam→const array multiple typeconst ░name: (░type | ░type) = [░]█
cp→const promiseconst ░name = new Promise((resolve, reject) => {
  █
})
const ░name = new Promise((resolve, reject) => {
  █
})

Destructuring

TriggerDescriptionResult JS/TS
cod→const object destconst {░prop, ░prop} = ░name█
cods→const object dest safeconst {░prop, ░prop} = ░name || {}█
codr→const object dest with restconst {░prop, ░prop, ...rest} = ░name█
cad→const array destconst [░prop, ░prop] = ░name█
cads→const array dest safeconst [░prop, ░prop] = ░name || []█
cadr→const array dest with restconst [░prop, ░prop, ...rest] = ░name█
pd→parameter object dest{░prop, ░prop}█
pdr→parameter object dest with rest{░prop, ░prop, ...rest}█

Object Elements

TriggerDescriptionResult JS/TS
oev→obj element variable░key: ░value,█
oes→obj element string░key: '░value',█
oen→obj element number░key: ░number,█
oeb→obj element boolean░key: ░true,█
oeo→obj element object░key: { ░element },█
oeom→obj element object multiline░key: {
  ░element, ░
},█
oea→obj element array░key: [ ░value ],█
oeam→obj element array multiline░key: [
  ░value, ░
],█

JSON Elements

TriggerDescriptionResult JS/TS
jes→json element string░key: '░value',█
jev→json element variable░key: ░value,█
jen→json element number░key: ░number,█
jeb→json element boolean░key: ░true,█
jeo→json element object░key: { ░element },█
jeom→json element object multiline░key: {
  ░element ,░
},█
jea→json element array░key: [ ░value ],█
jeam→json element array multiline░key: [
  ░value ,░
],█

ℹ️ Only available in.json,.jsonc and.json5 files

React

TriggerDescriptionResult JSX/TSX
rhe→react handle eventconst handle░Event = (event) => {
  const {name, value} = event.target
  █
}
rhen→react handle event as numberconst handle░Event = (event) => {
  const {name, valueAsNumber} = event.target
  █
}
rhed→react handle event as dateconst handle░Event = (event) => {
  const {name, valueAsDate} = event.target
  █
}

React Components

TriggerDescriptionResult JSX/TSX
rp→react property░prop={░prop}█
rps→react property string░prop='░'█
rpn→react property number░prop={░0}█
rpb→react property boolean░prop={░true}█
rpo→react property object░prop={{░}}█
rpa→react property array░prop={[░]}█
rpcn→react property classNameclassName='░'█
rpocl→react property onClickonClick={░handleClick}█
rpoch→react property onChangeonChange={░handleChange}█

ℹ️ Only available injsx ortsx

Back to menu


Examples

Creating properties on a React component withrp,rpn andrpb

React

Back to menu


Keyboard

Remember to complement the snippets with these keyboard shortcuts that can be used without needing to move the cursor to the start or to the end.

ActionWin/LinuxmacOS
Insert line abovectrl+shift+entercmd+shift+enter
Insert line belowctrl+entercmd+enter

Back to menu


Settings

Theeditor.snippetSuggestions setting in vscodesettings.json will show snippets on top of the suggestion list.

"editor.snippetSuggestions":"top"

Back to menu


About

Built With

  • VS Code - Code editing redefined.
  • Figma - The collaborative interface design tool.
  • SWPM - One Package Manager to command them all.

Contributing

Please readCONTRIBUTING for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We useSemVer for versioning. For the versions available, see theConst & Props Snippets on GitHub.

Authors

See also the list ofcontributors who participated in this project.

Sponsors

If this project helps you, consider buying me a cup of coffee.

GitHub Sponsorspaypal

License

This project is licensed under the MIT License - see theLICENSE file for details.

Back to menu

Sponsor this project

  •  

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp