Effect CommunityEC
Effect Community15mo ago
20 replies
atooni

Troubleshooting TypeScript Error with Effect and FileSystem Abstraction

I am sorry if this is a stupid question - I am trying to use effect 3.9.1, @effect/platform 0.68.4 and @effect/platform-node 0.63.4. I fail to define a single function that would use the File System abstraction.
I have reduced the code to
import * as Effect from "effect/Effect"
import * as FileSystem from "@effect/platform/FileSystem";

const foo =  Effect.gen(function* ($) {
  const fs = yield* $(FileSystem.FileSystem)
  return fs.readFile("bla")
})

This leads to a compiler error that I fail to understand - I am fairly convinced I missed something in the docs, but cant find it - My code looks like a very simple excerpt from the platform docs:
  tb-simulator/src/main.ts:9:23 - error TS2345: Argument of type 'Tag<FileSystem, FileSystem>' is not assignable to parameter of type 'Effect<unknown, unknown, unknown>'.
        Type 'Tag<FileSystem, FileSystem>' is missing the following properties from type 'Effect<unknown, unknown, unknown>': [EffectTypeId], [SinkTypeId], [StreamTypeId], [ChannelTypeId]

         7 |
         8 | const foo =  Effect.gen(function* ($) {
      >  9 |   const fs = yield* $(FileSystem.FileSystem)
           |                       ^
        10 |   return fs.readFile("bla")
        11 | })
        12 |
Was this page helpful?