sindresorhus/screenfull

Typings for 5.0.0 export only isEnabled

DirtyHairy opened this issue · 2 comments

The current typings for 5.0.0 render the library unusable without an explicit cast. The typings read

interface Screenfull {
     // [...]
    readonly isEnabled: boolean;
     // [...]
}

and

declare const screenfull: screenfull.Screenfull | {isEnabled: false};

I suppose the intention is to force a check on isEnabled before the API is accessible; however, this would require the interface to be

interface Screenfull {
     // [...]
    readonly isEnabled: true;
     // [...]
}

With the current typings, the only exported property is isEnabled, rendering the library unusable. The only workaround that I could come up with is an explicit cast:

import _screenfull, { Screenfull } from 'screenfull';
const screenfull = _screenfull as Screenfull;

Thanks alot!

Hi, I still cannot call screenfull.isEnabled but only screenfull.enabled
the typing seems not to be working for me. I am on "screenfull": "^5.0.2"