typescript

Enforce TypeScript coding standards for consistent, safe code.

1.0k|453|Updated Jun 21, 2017
One-click install
npx skills add https://github.com/forcedotcom/salesforcedx-vscode --skill typescript-forcedotcom
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript
Source: https://github.com/forcedotcom/salesforcedx-vscode/tree/main/.claude/skills/typescript
Command: npx skills add https://github.com/forcedotcom/salesforcedx-vscode --skill typescript-forcedotcom

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TypeScript coding standards and conventions codify policy to promote consistency, readability, and safer, more maintainable code across projects.

Core Features & Use Cases

  • no barrel files
  • avoid type assertions (as Foo or as unknown as or Foo!). do guards or Effect.schema stuff (ex is) instead
  • no void for async - use async/effect (exception vscode-window-messages)
  • no export * - name exports explicitly
  • prefer undefined over null (unless server requires null)
  • prefer undefined over empty string
  • prefer map/filter over loops/conditionals
  • avoid mutation
  • avoid any
  • no enums or namespaces (enums compile to weird JS; use string union types instead; exception: interfaces defined outside this repo that we can't change)
  • no runtime errors for developer mistakes (use types to ensure exhaustive switch/case; don't throw for null/undefined when input/consumer is within our control)
  • .ts filenames: camelCase, no hyphens, no leading capitals
  • preserve comments when refactoring; remove if wrong/obsolete
  • exported functions: single-line jsdoc /*_ foo _/ if name unclear; no params/return (TS provides types)
  • look for uses of (Object|Map).groupBy instead of older patterns

Quick Start

Follow these rules when writing or refactoring TypeScript to ensure consistent, safe code.

Frequently Asked Questions about typescript

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce consistent TypeScript coding standards across my projects?

TypeScript coding standards are enforced by applying rules that restrict unsafe patterns like type assertions and barrel files, while mandating explicit exports and naming conventions to ensure safe, maintainable code.

Why should I avoid type assertions in TypeScript refactoring?

Avoid type assertions during TypeScript refactoring because they bypass the type checker, creating unsafe code. Instead, use type guards or schema validation to ensure runtime type safety.

What is the best way to handle null and undefined values in TypeScript?

Prefer undefined over null and empty strings in TypeScript, unless an external server specifically requires null values, to maintain consistent data representation.

Can I use enums and namespaces in my TypeScript codebase?

Avoid enums and namespaces in your TypeScript codebase because enums compile to unexpected JavaScript. Use string union types instead for safer and more predictable runtime behavior.

How do I prevent runtime errors for developer mistakes in TypeScript?

Prevent runtime errors for developer mistakes in TypeScript by using types to ensure exhaustive switch and case statements, and avoid throwing errors for null or undefined when the consumer is within your control.

What naming conventions should I use for TypeScript files and exports?

TypeScript file naming conventions require camelCase filenames with no hyphens or leading capitals. Additionally, explicitly name all exports instead of using wildcard export statements.