Subscribe on changes!

Re-enable EffectScope.active in public TypeScript types

avatar
Jun 27th 2022

Vue version

3.2.37

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-98hvi1?file=src%2Fmain.ts&terminal=dev

Steps to reproduce

Attempt to access the active property of an effectScope in a TypeScript project.

What is expected?

The active property should be publicly accessible as Vue provides no other (public) means for checking whether a scope is active.

What is actually happening?

The active property is excluded in public types.

System Info

No response

Any additional comments?

I understand some members of the EffectScope type have been excluded from the published typings as they are considered internal:

export declare class EffectScope {
    /* Excluded from this release type: active */
    /* Excluded from this release type: effects */
    /* Excluded from this release type: cleanups */
    /* Excluded from this release type: parent */
    /* Excluded from this release type: scopes */
    /* Excluded from this release type: index */
    constructor(detached?: boolean);
    run<T>(fn: () => T): T | undefined;
    /* Excluded from this release type: on */
    /* Excluded from this release type: off */
    stop(fromParent?: boolean): void;
}

Marking most of these members as internal makes sense, however, some library authors such as myself rely on the active property of an effectScope to check whether a scope is currently active.

As far as I am aware there is no alternative method for checking whether a scope is currently active.

Bear in mind this is purely a compile-time issue and does not affect runtime operation.