fundamentals_skill
- Python
1
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill pluginagentmarketplace/custom-plugin-typescript --skill fundamentals- SKILL.md1.1 KB
Overview
This skill teaches TypeScript type system fundamentals and common typing patterns to help you write safer, more predictable code. It covers primitive and composite types, interfaces, type aliases, function typing, and essential concepts like type inference and narrowing. By the end, you will be able to add clear, maintainable types to JavaScript projects.
How this skill works
The skill presents concise explanations and examples for each core topic: basic types, annotations, interfaces, aliases, and function types. It highlights practical patterns such as optional and readonly properties, union/intersection types, generics, and overloads, and shows how type inference and assertions interact with explicit annotations. Each concept is framed around typical coding scenarios so you can apply types incrementally to an existing codebase.
When to use it
- Adding type safety to a JavaScript codebase or new TypeScript project
- Defining clear APIs with interfaces and type aliases
- Writing reusable, generic functions and libraries
- Refactoring loosely typed code to reduce runtime errors
- Learning to use union types and narrowing for safer control flow
Best practices
- Prefer specific types over any; use unknown when input must be validated first
- Rely on type inference for local variables and annotate public API surfaces
- Use interfaces for object shapes and type aliases for unions/intersections
- Favor readonly and optional modifiers to express intent and immutability
- Introduce generics for reusable components and keep signatures narrow
- Use discriminated unions for safe runtime branching and clear narrowing
Example use cases
- Annotating function parameters and return values to document and enforce behavior
- Modeling API responses with interfaces and optional properties
- Creating utility types with aliases, unions, and intersections
- Building generic data structures like typed containers or mappers
- Refactoring callbacks and event handlers with precise function types
FAQ
Use interfaces to describe object shapes and support declaration merging; use type aliases for unions, intersections, primitives, and more complex type expressions.
Is it okay to use any during migration?
Temporary use of any can speed migration, but prefer unknown or gradual typing techniques to avoid losing type safety permanently.