Error when using Effect.bind() with catchTag
Hey!
I'm trying to do a catchTag after using Effect.bind() but I'm getting this error:
What am I doing wrong?
Err:
I'm trying to do a catchTag after using Effect.bind() but I'm getting this error:
What am I doing wrong?
const program = Effect.Do.pipe(
Effect.tap(() => Effect.log('Parsing env variables...')),
Effect.bind('env', () =>
Effect.tryPromise(() => EnvSchema.parseAsync(env.parsed)),
),
Effect.tap(() => Effect.log('Initalizing Fastify web server and routes...')),
Effect.bind('fastifyInstance', ({ env }) =>
Effect.sync(() => initFastify(parseInt(env.FASTIFY_PORT, 10))),
),
Effect.tap(({ env }) =>
Effect.log(`Started fastify on port ${env.FASTIFY_PORT}`),
),
Effect.bind('admin-user', ({ env }) =>
Effect.tryPromise({
try: async () =>
await db(env.PLANETSCALE_URL).insert(users).values({
username: env.SYSADMIN_USERNAME,
password: env.SYSADMIN_PASSWORD,
email: env.SYSADMIN_EMAIL,
}),
catch: () => new InsertAdminError(),
}),
),
Effect.tap(() => Effect.log('Inserted admin user to DB')),
Effect.catchTag('InsertAdminError', (_err) => Effect.succeed('err')),
);const program = Effect.Do.pipe(
Effect.tap(() => Effect.log('Parsing env variables...')),
Effect.bind('env', () =>
Effect.tryPromise(() => EnvSchema.parseAsync(env.parsed)),
),
Effect.tap(() => Effect.log('Initalizing Fastify web server and routes...')),
Effect.bind('fastifyInstance', ({ env }) =>
Effect.sync(() => initFastify(parseInt(env.FASTIFY_PORT, 10))),
),
Effect.tap(({ env }) =>
Effect.log(`Started fastify on port ${env.FASTIFY_PORT}`),
),
Effect.bind('admin-user', ({ env }) =>
Effect.tryPromise({
try: async () =>
await db(env.PLANETSCALE_URL).insert(users).values({
username: env.SYSADMIN_USERNAME,
password: env.SYSADMIN_PASSWORD,
email: env.SYSADMIN_EMAIL,
}),
catch: () => new InsertAdminError(),
}),
),
Effect.tap(() => Effect.log('Inserted admin user to DB')),
Effect.catchTag('InsertAdminError', (_err) => Effect.succeed('err')),
);Err:
Argument of type '<R, A>(self: Effect<R, { _tag: string; }, A>) => Effect<R, { _tag: string; }, string | A>' is not assignable to parameter of type '(_: Effect<never, unknown, { env: { FASTIFY_PORT: string; PLANETSCALE_URL: string; SYSADMIN_USERNAME: string; SYSADMIN_PASSWORD: string; SYSADMIN_EMAIL: string; }; fastifyInstance: Either<FastifyInitError, FastifyInstance<...>>; "admin-user": ExecutedQuery; }>) => Effect<...>'.
Types of parameters 'self' and '_' are incompatible.
Type 'Effect<never, unknown, { env: { FASTIFY_PORT: string; PLANETSCALE_URL: string; SYSADMIN_USERNAME: string; SYSADMIN_PASSWORD: string; SYSADMIN_EMAIL: string; }; fastifyInstance: Either<FastifyInitError, FastifyInstance<...>>; "admin-user": ExecutedQuery; }>' is not assignable to type 'Effect<never, { _tag: string; }, { env: { FASTIFY_PORT: string; PLANETSCALE_URL: string; SYSADMIN_USERNAME: string; SYSADMIN_PASSWORD: string; SYSADMIN_EMAIL: string; }; fastifyInstance: Either<FastifyInitError, FastifyInstance<...>>; "admin-user": ExecutedQuery; }>'.
Type 'unknown' is not assignable to type '{ _tag: string; }'.Argument of type '<R, A>(self: Effect<R, { _tag: string; }, A>) => Effect<R, { _tag: string; }, string | A>' is not assignable to parameter of type '(_: Effect<never, unknown, { env: { FASTIFY_PORT: string; PLANETSCALE_URL: string; SYSADMIN_USERNAME: string; SYSADMIN_PASSWORD: string; SYSADMIN_EMAIL: string; }; fastifyInstance: Either<FastifyInitError, FastifyInstance<...>>; "admin-user": ExecutedQuery; }>) => Effect<...>'.
Types of parameters 'self' and '_' are incompatible.
Type 'Effect<never, unknown, { env: { FASTIFY_PORT: string; PLANETSCALE_URL: string; SYSADMIN_USERNAME: string; SYSADMIN_PASSWORD: string; SYSADMIN_EMAIL: string; }; fastifyInstance: Either<FastifyInitError, FastifyInstance<...>>; "admin-user": ExecutedQuery; }>' is not assignable to type 'Effect<never, { _tag: string; }, { env: { FASTIFY_PORT: string; PLANETSCALE_URL: string; SYSADMIN_USERNAME: string; SYSADMIN_PASSWORD: string; SYSADMIN_EMAIL: string; }; fastifyInstance: Either<FastifyInitError, FastifyInstance<...>>; "admin-user": ExecutedQuery; }>'.
Type 'unknown' is not assignable to type '{ _tag: string; }'.