Skip to content

Latest commit

 

History

History
176 lines (134 loc) · 3.63 KB

File metadata and controls

176 lines (134 loc) · 3.63 KB
title Set Up Your Effect Development Environment
id tooling-hello-world
skillLevel beginner
applicationPatternId tooling-and-debugging
summary Configure your editor and tools for the best Effect development experience.
tags
tooling
setup
vscode
getting-started
rule
description
Install the Effect extension and configure TypeScript for optimal Effect development.
author PaulJPhilp
related
tooling-effect-lsp
getting-started-hello-world
lessonOrder 2

Guideline

Set up your development environment with the Effect extension and proper TypeScript configuration for the best experience.


Rationale

A well-configured environment helps you:

  1. See types clearly - Effect types can be complex
  2. Get better autocomplete - Know what methods are available
  3. Catch errors early - TypeScript finds problems
  4. Navigate easily - Go to definitions, find references

Setup Steps

1. Install Effect

# Using Bun (recommended)
bun add effect

# Or npm
npm install effect

# Or pnpm
pnpm add effect

2. Configure TypeScript

Create or update tsconfig.json:

{
  "compilerOptions": {
    "target": "ES2022",
    "module": "NodeNext",
    "moduleResolution": "NodeNext",
    "strict": true,
    "exactOptionalPropertyTypes": true,
    "noUncheckedIndexedAccess": true,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "esModuleInterop": true,
    "skipLibCheck": true,
    "declaration": true,
    "sourceMap": true
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules"]
}

3. Install VS Code Extensions

Install the Effect extension for VS Code:

  1. Open VS Code
  2. Go to Extensions (Cmd+Shift+X)
  3. Search for "Effect"
  4. Install the official Effect extension

The extension provides:

  • Better type display (unwraps complex Effect types)
  • Quick fixes and refactorings
  • Inline error previews
  • Go to definition for Effect functions

4. VS Code Settings (Optional)

Add to .vscode/settings.json for better Effect experience:

{
  "typescript.preferences.includePackageJsonAutoImports": "on",
  "typescript.inlayHints.functionLikeReturnTypes.enabled": true,
  "typescript.inlayHints.parameterTypes.enabled": true,
  "editor.formatOnSave": true
}

Verify Setup

Create a test file to verify everything works:

// src/hello.ts
import { Effect, Console } from "effect"

const program = Effect.gen(function* () {
  yield* Console.log("Effect is working!")
  return 42
})

// Hover over 'result' - should show: Effect<number, never, never>
const result = program

// Run it
Effect.runPromise(result).then(console.log)

Run it:

bun src/hello.ts
# Output: Effect is working!
# Output: 42

Key Editor Features

Feature How to Use
Hover for types Hover over any variable
Go to definition Cmd+Click on a function
Find references Right-click → Find All References
Autocomplete Type . after an Effect
Quick fix Click lightbulb or Cmd+.

Project Structure

Recommended structure for Effect projects:

my-project/
├── src/
│   ├── index.ts       # Entry point
│   ├── services/      # Effect services
│   ├── errors/        # Tagged errors
│   └── utils/         # Helper functions
├── test/
│   └── *.test.ts      # Tests
├── package.json
└── tsconfig.json

Next Steps

  1. Try the Getting Started patterns
  2. Install the Effect LSP for advanced features
  3. Explore the Effect documentation