This is the Effect library repository, focusing on functional programming patterns and effect systems in TypeScript.
- The git base branch is
main - Use
pnpmas the package manager - Run
pnpm lint-fixafter editing files - Always run tests after making changes:
pnpm test <test_file.ts> - Run type checking:
pnpm check:tsgo- If type checking continues to fail, run
pnpm cleanto clear caches, then re-runpnpm check:tsgo
- If type checking continues to fail, run
- Check JSDoc examples compile:
pnpm docgen
You MUST look at the ./.patterns/ directory as well as existing code in
the repository to learn and follow established patterns before writing new code.
Instead of writing:
const fn = (param: string) =>
Effect.gen(function*() {
// ...
})Prefer:
const fn = Effect.fnUntraced(function*(param: string) {
// ...
})Prefer the class syntax when working with Context.Service. For example:
import { Context } from "effect"
class MyService extends Context.Service<MyService, {
readonly doSomething: (input: string) => number
}>()("MyService") {}The index.ts files are automatically generated. Do not manually edit them. Use
pnpm codegen to regenerate barrel files after adding or removing modules.
If you need to run some code for testing or debugging purposes, create a new
file in the scratchpad/ directory at the root of the repository. You can then
run the file with node scratchpad/your-file.ts.
Make sure to delete the file after you are done testing.
Before writing tests, always look at existing tests in the codebase for similar functionality to follow established patterns.
- Test files are located in
packages/*/test/directories for each package - Main Effect library tests:
packages/effect/test/ - Always verify implementations with tests
- Run specific tests with:
pnpm test <filename>
- Use
it.effectfor all Effect-based tests, notEffect.runSyncwith regularit - Import
{ assert, describe, it }from@effect/vitest - Never use
expectfrom vitest in Effect tests - useassertmethods instead - All tests should use
it.effect("description", () => Effect.gen(function*() { ... }))
Type level tests are located in the packages/*/typetest directories of each package.
You can run them with pnpm test-types <filename>.
Take a look at the existing .tst.ts files for examples of how to write type
level tests. They use the tstyche testing library.
Refer to ai-docs/README.md for instructions on how to write AI documentation.
Read it very carefully before writing AI documentation examples.
AI documentation changes can ignore the "Reduce comments" guideline. You can add comments to AI documentation examples as needed to explain the code.
All pull requests must include a changeset. You can create changesets in the
.changeset/ directory.
The have the following format:
---
"package-name": patch | minor | major
---
A description of the change.