Zed TypeScript Snippets
A comprehensive collection of TypeScript snippets for Zed editor, designed to accelerate TypeScript development with intelligent type support and modern patterns.
✨ Features
- 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
📦 Installation
Via Zed Extensions (Recommended)
- Open Zed editor
- Press
Cmd/Ctrl + Shift + Pto open the command palette - Type "extensions" and select "zed: extensions"
- Search for "TypeScript Snippets"
- Click "Install"
Manual Installation
Clone this repository:
git clone https://github.com/seekode/zed-ts-snippetsCopy the extension to your Zed extensions directory:
- macOS:
~/.config/zed/extensions/ - Linux:
~/.config/zed/extensions/ - Windows:
%APPDATA%\Zed\extensions\
- macOS:
Restart Zed
🚀 Usage
Simply start typing any prefix. The snippets will appear in the autocomplete menu.
Quick Start Examples
| 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 |
📋 Available Snippets
Console Methods
log- Console logwarn- Console warnerror- Console errortable- Console tabletime- Console time/timeEnd
Functions & Arrow Functions
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
Types & Interfaces
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
Advanced Types
mtyp- Mapped typectyp- Conditional typetlit- Template literal typeidx- Index signaturekeyof- keyof operatortof- typeof operatorinfer- infer keywordawaited- Awaited utility type
Utility Types
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
Loops & Iteration
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
Conditionals
if- If statementifelse- If...else statementelse- Else if statementter- Ternary operatorswitch- Switch statement
Error Handling
try- Try...catch block with typed errortryf- Try...catch...finallyterr- Throw errorcerr- Custom error class
Promises & Async
prom- New Promise with typethen- Promise then/catch with typesawait- Await expression with typeawaitt- Await with try/catch and types
Classes
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
Decorators
dec- Class decoratormdec- Method decoratorpdec- Property decoratorpardec- Parameter decorator
Modules & Namespaces
ns- Namespace declarationmod- Module declarationdmod- Declare moduledglobal- Declare global
Import/Export
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
Variables & Destructuring
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
Objects
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
Arrays & Collections
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
Strings
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
Timers
timeout- setTimeoutinterval- setIntervalctimeout- clearTimeoutcinterval- clearInterval
Fetch & JSON
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)
DOM Manipulation
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
Storage
lset- localStorage.setItem()lget- localStorage.getItem()lrem- localStorage.removeItem()lclear- localStorage.clear()sset- sessionStorage.setItem()sget- sessionStorage.getItem()
Advanced Features
gen- Generator function with typesagen- Async generator with typesproxy- Proxy object with typerget- Reflect.get()sym- Symbolsymf- Symbol.for()
Regular Expressions
re- RegExp patternretest- RegExp test
Math & Date
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
Operators & Keywords
tof- typeof checkinst- instanceof checknc- Nullish coalescing (??)oc- Optional chaining (?.)nna- Non-null assertion (!)sat- satisfies operatorasc- as const assertionrop- Readonly propertyop- Optional property
Documentation
com- Comment blockdoc- TSDoc function documentationdocc- TSDoc class documentationdoci- TSDoc interface documentation
🎯 Smart Placeholders
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 typeThe $0 placeholder indicates the final cursor position.
🛠️ Customization
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};"]
}
}🤝 Contributing
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.
Development Setup
- Fork the repository
- Clone your fork
- Make your changes
- Test in Zed
- Submit a pull request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Zed Team for creating an amazing editor
- TypeScript team for the incredible type system
- VSCode community for prefix inspiration
- Community feedback and contributions
📞 Support
- Issues: GitHub Issues
- Zed Community: Zed Discord
- Documentation: Zed Documentation
Happy coding with Zed and TypeScript! 🚀