A comprehensive collection of TypeScript snippets for Zed editor, designed to accelerate TypeScript development with intelligent type support and modern patterns.
- Complete TypeScript Coverage: 200+ snippets covering types, interfaces, generics, and advanced features
- Type-First Approach: All snippets include proper TypeScript type annotations
- Short & Convenient Prefixes: VSCode-inspired short prefixes for faster coding
- Smart Placeholders: Tab-navigable placeholders for efficient coding
- Modern TypeScript: Support for latest TypeScript features including utility types, decorators, and more
- Async/Await Support: Modern asynchronous programming patterns with proper typing
- Advanced Types: Generics, conditional types, mapped types, and utility types
- Class & OOP: Full support for classes, interfaces, abstract classes, and decorators
- Open Zed editor
- Press
Cmd/Ctrl + Shift + P
to open the command palette - Type "extensions" and select "zed: extensions"
- Search for "TypeScript Snippets"
- Click "Install"
-
Clone this repository:
git clone https://github.com/seekode/zed-ts-snippets
-
Copy the extension to your Zed extensions directory:
- macOS:
~/.config/zed/extensions/
- Linux:
~/.config/zed/extensions/
- Windows:
%APPDATA%\Zed\extensions\
- macOS:
-
Restart Zed
Simply start typing any prefix. The snippets will appear in the autocomplete menu.
Prefix | Output | Description |
---|---|---|
log |
console.log($0) |
Console log statement |
int |
interface Name { property: Type; } |
TypeScript interface |
typ |
type TypeName = Type; |
Type alias |
af |
const name = (params): ReturnType => {} |
Typed arrow function |
asf |
async function name(): Promise<Type> {} |
Async function with typing |
cls |
class ClassName { constructor() {} } |
TypeScript class |
enu |
enum EnumName { Member = Value } |
Enum declaration |
gfn |
function name<T>(param: T): ReturnType {} |
Generic function |
log
- Console logwarn
- Console warnerror
- Console errortable
- Console tabletime
- Console time/timeEnd
fn
- Typed function declarationaf
- Typed arrow functionafe
- Arrow function (implicit return) with typeasf
- Async function with Promise return typeasa
- Async arrow functionafn
- Anonymous typed functioniife
- Immediately Invoked Function Expressionaiife
- Async IIFEgfn
- Generic functiongaf
- Generic arrow function
int
- Interface declarationtyp
- Type aliasenu
- Enum declarationcenu
- Const enumgint
- Generic interfacegtyp
- Generic type aliasunion
- Union typeinter
- Intersection typelit
- Literal typetg
- Type guard functionas
- Type assertion
mtyp
- Mapped typectyp
- Conditional typetlit
- Template literal typeidx
- Index signaturekeyof
- keyof operatortof
- typeof operatorinfer
- infer keywordawaited
- Awaited utility type
pick
- Pick utility typeomit
- Omit utility typepartial
- Partial utility typerequired
- Required utility typereadonly
- Readonly utility typerecord
- Record utility typeexclude
- Exclude utility typeextract
- Extract utility typenonnull
- NonNullable utility typertype
- ReturnType utility typeparams
- Parameters utility type
for
- For loopforof
- For...of loopforin
- For...in loopwhile
- While loopdowhile
- Do...while loopfre
- Array forEach with typesmap
- Array map with typesfilter
- Array filter with typesreduce
- Array reduce with typesfind
- Array find with typesfindex
- Array findIndex with typessome
- Array some with typesevery
- Array every with types
if
- If statementifelse
- If...else statementelse
- Else if statementter
- Ternary operatorswitch
- Switch statement
try
- Try...catch block with typed errortryf
- Try...catch...finallyterr
- Throw errorcerr
- Custom error class
prom
- New Promise with typethen
- Promise then/catch with typesawait
- Await expression with typeawaitt
- Await with try/catch and types
cls
- Class declarationclsp
- Class with typed propertiesclsm
- Class with typed methodacls
- Abstract classclsi
- Class implements interfaceclse
- Class extendsget
- Getter method with typeset
- Setter method with typestatic
- Static method with typegcls
- Generic class
dec
- Class decoratormdec
- Method decoratorpdec
- Property decoratorpardec
- Parameter decorator
ns
- Namespace declarationmod
- Module declarationdmod
- Declare moduledglobal
- Declare global
imp
- Import defaultimpn
- Import namedimpt
- Import typeimpa
- Import all (as)impd
- Dynamic importexp
- Export defaultexpn
- Export namedexpt
- Export typeexpa
- Export allexpf
- Export typed functionexpc
- Export typed constexpi
- Export interfaceexpta
- Export type alias
const
- Typed const declarationlet
- Typed let declarationvar
- Typed var declarationca
- Const assertion (as const)darr
- Typed array destructuringdobj
- Typed object destructuringsarr
- Spread arraysobj
- Spread objectrest
- Rest parameters with type
obj
- Object literaltobj
- Typed objectobjm
- Object with typed methodobjs
- Object shorthandobjc
- Object computed propertyokeys
- Object.keys() with proper typingovals
- Object.values()oents
- Object.entries() with proper typingoassign
- Object.assign() with typesofreeze
- Object.freeze()oseal
- Object.seal()ocreate
- Object.create() with type
arr
- Array literaltarr
- Typed arrayarrg
- Array with generic typerarr
- Readonly arraytup
- Tuple typeafrom
- Array.from() with typeaof
- Array.of() with typeset
- New Set with typenmap
- New Map with typeswset
- New WeakSet with typewmap
- New WeakMap with types
tpl
- Template literaltlit
- Template literal typettag
- Tagged templatematch
- String matchreplace
- String replacesplit
- String splittrim
- String triminc
- String includesstarts
- String startsWithends
- String endsWithpstart
- String padStartpend
- String padEndrepeat
- String repeat
timeout
- setTimeoutinterval
- setIntervalctimeout
- clearTimeoutcinterval
- clearInterval
fetch
- Fetch API with typesfeta
- Fetch async/await with typesfetp
- Fetch POST request with typesfetg
- Generic fetch functionjparse
- JSON.parse() with type assertionjstring
- JSON.stringify()jstringp
- JSON.stringify() (pretty)
qs
- querySelector with generic typeqsa
- querySelectorAll with generic typegel
- getElementById with type assertiongclass
- getElementsByClassName with typegtag
- getElementsByTagName with typecel
- createElementael
- addEventListener with typed eventrel
- removeEventListenerdomr
- DOMContentLoadedwinl
- Window load eventraf
- requestAnimationFrame
lset
- localStorage.setItem()lget
- localStorage.getItem()lrem
- localStorage.removeItem()lclear
- localStorage.clear()sset
- sessionStorage.setItem()sget
- sessionStorage.getItem()
gen
- Generator function with typesagen
- Async generator with typesproxy
- Proxy object with typerget
- Reflect.get()sym
- Symbolsymf
- Symbol.for()
re
- RegExp patternretest
- RegExp test
mrand
- Math.random()mfloor
- Math.floor()mceil
- Math.ceil()mround
- Math.round()mmax
- Math.max()mmin
- Math.min()dnow
- Date.now()date
- New Date()iso
- ISO date string
tof
- typeof checkinst
- instanceof checknc
- Nullish coalescing (??)oc
- Optional chaining (?.)nna
- Non-null assertion (!)sat
- satisfies operatorasc
- as const assertionrop
- Readonly propertyop
- Optional property
com
- Comment blockdoc
- TSDoc function documentationdocc
- TSDoc class documentationdoci
- TSDoc interface documentation
Snippets use numbered placeholders ($1
, $2
, etc.) that you can tab through:
// Typing 'int' + Tab
interface InterfaceName {
property: Type;
}
// Tab to InterfaceName, type name, Tab to property, type property name, Tab to Type, type the type
The $0
placeholder indicates the final cursor position.
You can modify snippets by editing the snippets/typescript.json
file. Each snippet follows this structure:
{
"Snippet Name": {
"prefix": "trigger-text",
"body": ["const ${1:name}: ${2:Type} = ${3:value};"]
}
}
Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.
- Fork the repository
- Clone your fork
- Make your changes
- Test in Zed
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Zed Team for creating an amazing editor
- TypeScript team for the incredible type system
- VSCode community for prefix inspiration
- Community feedback and contributions
- Issues: GitHub Issues
- Zed Community: Zed Discord
- Documentation: Zed Documentation
Happy coding with Zed and TypeScript! π