Skip to content

Latest commit

 

History

History
62 lines (49 loc) · 1.55 KB

File metadata and controls

62 lines (49 loc) · 1.55 KB
title Set Up a New Effect Project
id setup-new-project
skillLevel beginner
applicationPatternId project-setup--execution
summary Initialize a new Node.js project with the necessary TypeScript configuration and Effect dependencies to start building.
tags
project-setup
getting-started
typescript
tsconfig
npm
pnpm
bun
rule
description
Set up a new Effect project.
related
execute-with-runpromise
author Paul Philp
lessonOrder 17

Set Up a New Effect Project

Guideline

To start a new Effect project, initialize a standard Node.js project, add effect and typescript as dependencies, and create a tsconfig.json file with strict mode enabled.

Rationale

A proper setup is crucial for leveraging Effect's powerful type-safety features. Using TypeScript's strict mode is non-negotiable.

Good Example

// 1. Init project (e.g., `npm init -y`)
// 2. Install deps (e.g., `npm install effect`, `npm install -D typescript tsx`)
// 3. Create tsconfig.json with `"strict": true`
// 4. Create src/index.ts
import { Effect } from "effect";

const program = Effect.log("Hello, World!");

Effect.runSync(program);

// 5. Run the program (e.g., `npx tsx src/index.ts`)

Explanation:
This setup ensures you have TypeScript and Effect ready to go, with strict type-checking for maximum safety and correctness.

Anti-Pattern

Avoid disabling strict mode in your tsconfig.json. Running with "strict": false will cause you to lose many of the type-safety guarantees that make Effect so powerful.