Effect CommunityEC
Effect Community2y ago
75 replies
addamsson

Troubleshooting `ContextTag` Class Integration Issues in TypeScript

Ever since the new ContextTag class was introduced I'm having all sorts of problems all the time such as:
The inferred type of 'SubscribeToDailySync' cannot be named without a reference to '../../../node_modules/@cobalt/authorization/src/Context'. This is likely not portable. A type annotation is necessary.

This Context is a tag that I export from my library:
export class Context extends EffectContext.Tag("Context/Authorization")<
    Context,
    {
        /**
         * The authorization information for the application.
         */
        readonly authorization: Descriptor;
        /**
         * The user that is trying to execute the operation.
         */
        readonly executedBy: User;
    }
>() {}

is there a way to get rid of these errors? Right now I have to import this Context object and it is awkward to just have this:
import { Authorization } from "@cobalt/authorization";
Authorization.Context;

everywhere I use a context Tag.
Was this page helpful?