Tools
The efs command
| Command | What it does |
|---|---|
efs build [paths] | Compile .efs files, next to each source by default. |
efs check [path] | Type check the project with tsrs and report errors at their EffScript position. |
efs fmt [paths] | Format files. |
efs lint [paths] | Run the lint rules. |
efs emit FILE | Print the generated code for one file. |
efs type-at FILE:LINE:COL | Print the inferred type at a position. |
efs lsp | Run the language server. |
efs mapper | Serve the TypeScript content-mapper protocol (see TypeScript interop). |
efs init [dir] | Create a project. |
Paths default to the current directory, and directories are searched for .efs
files (skipping node_modules, target, dist, build and hidden
directories).
efs build
| Option | |
|---|---|
--emit ts | Write TypeScript (the default). |
--emit js | Write JavaScript. Types are dropped, and imports used only as types are removed. |
--declaration | With --emit js, also write .d.ts files. Their types are inferred by tsrs from the whole program, so the source needs no extra annotations. |
--source-map | Write a source map next to each output, pointing back to the .efs source. |
--out-dir DIR | Write output under DIR, keeping the source layout. |
--import-extension EXT | The extension that replaces .efs in relative imports (default .js). |
--watch | Rebuild when files change. |
Every output starts with // Generated by efs from <file>. Do not edit., and
efs build never overwrites a file without that line, so a hand-written
foo.ts next to foo.efs is safe: you get an error instead.
efs check
| Option | |
|---|---|
--effect | Also report the Effect Language Service's diagnostics from effect-tsgo. |
--efs-only | Only report diagnostics in .efs files. |
--json | Print one JSON object per diagnostic. |
$ efs checksrc/users.efs:37:30: error: Argument of type 'number' is not assignable to parameter of type 'string & Brand<"UserId">'. [ts2345] 37 | const user = run repo.find(42) | ^^checked 4 EffScript files in 95ms, 1 errorefs fmt
--check reports files that are not formatted instead of rewriting them, and
--stdin formats standard input. Formatting is idempotent, keeps every
comment, keeps your choice of one line or several for each bracketed
construct, and never changes the compiled output.
Like Prettier for TypeScript, efs fmt prints a ; after every statement and
line-style declaration (imports, const/let, expressions, return, fail,
emit, throw, type, export { }, service member signatures, machine
on/after transitions, component prop/let/event members), and none
after constructs that end in their own block (functions, if, for,
while, service, machine, component, update { }, ...).
Missing semicolons are added and existing ones are kept in place. Set
"fmt": { "semicolons": false } in efs.json to leave them out; the
formatter then removes the ones in the source. See
semicolons.
efs lint
--deny-warnings makes warnings fail the command, --disable RULE turns a
rule off, and --rules lists them. See lint rules.
efs emit
Prints the TypeScript for a file, or with --js the JavaScript. --source-map
prints a Source Map v3 and --span-map the span map in the TypeScript
content-mapper format.
efs.json
Optional configuration, read from the directory of the given path or above:
{ "importExtension": ".js", "prelude": true, "outDir": "gen", "emit": "js", "declaration": true, "sourceMap": true, "lint": { "disabled": ["unused-binding"] }, "fmt": { "semicolons": false }}fmt.semicolons defaults to true. prelude (default true) imports the
core Effect modules a file uses without importing them (see
Prelude); false turns it off. build, check, emit and the
language server follow it. Command-line options take precedence.