accurate-environment-model

Use when defining global types. Use when augmenting window. Use when typing environment variables. Use when working with build-time constants. Use when configuring type definitions.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "accurate-environment-model" with this command: npx skills add marius-townhouse/effective-typescript-skills/marius-townhouse-effective-typescript-skills-accurate-environment-model

Create an Accurate Model of Your Environment

Overview

Your TypeScript environment includes globals, environment variables, and platform-specific APIs. Create accurate type definitions for your environment using declaration files (.d.ts). This ensures type safety for platform-specific code and global variables.

When to Use This Skill

  • Defining global types
  • Augmenting window or globalThis
  • Typing environment variables
  • Working with build-time constants
  • Configuring type definitions

The Iron Rule

Model your environment accurately with .d.ts files. Declare globals, window properties, and environment variables that your code depends on.

Example

// types/environment.d.ts
declare global {
  interface Window {
    APP_CONFIG: {
      apiUrl: string;
      version: string;
    };
  }
  
  const BUILD_TIMESTAMP: number;
}

// Usage
console.log(window.APP_CONFIG.apiUrl);
console.log(BUILD_TIMESTAMP);

Reference

  • Effective TypeScript, 2nd Edition by Dan Vanderkam
  • Item 76: Create an Accurate Model of Your Environment

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

tsdoc-comments

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

code-gen-independent

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

tsconfig-options

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

module-by-module-migration

No summary provided by upstream source.

Repository SourceNeeds Review