Docs/CLI

Tools

The efs command

On this page›
CommandWhat 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 FILEPrint the generated code for one file.
efs type-at FILE:LINE:COLPrint the inferred type at a position.
efs lspRun the language server.
efs mapperServe 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 tsWrite TypeScript (the default).
--emit jsWrite JavaScript. Types are dropped, and imports used only as types are removed.
--declarationWith --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-mapWrite a source map next to each output, pointing back to the .efs source.
--out-dir DIRWrite output under DIR, keeping the source layout.
--import-extension EXTThe extension that replaces .efs in relative imports (default .js).
--watchRebuild 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
--effectAlso report the Effect Language Service's diagnostics from effect-tsgo.
--efs-onlyOnly report diagnostics in .efs files.
--jsonPrint one JSON object per diagnostic.
Text
$ 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 error

efs 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:

JSON
{  "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.

Edit this page on GitHub →
MIT licensedBuilt with EffScript, Effect UI and Tailwind CSSGitHub