Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Incorrect type definition for useFeatureEntitlements #393

Closed
hognevevle opened this issue Jan 12, 2024 · 4 comments
Closed

[BUG] Incorrect type definition for useFeatureEntitlements #393

hognevevle opened this issue Jan 12, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@hognevevle
Copy link

hognevevle commented Jan 12, 2024

const foo = useFeatureEntitlements("bar");

foo is now, according to Typescript, of type Entitlement.
During runtime, however, it is in fact a Ref<Entitlement>.

This causes problems when you're not directly using foo in the component html, but instead using it elsewhere in the script part.

You are then forced to do something like this:

(foo as unknown as Ref<typeof foo>).value.isEntitled
(alternatively unref(foo).isEntitled)

Proof:

  console.log("checking entitlement");
  console.log(foo.isEntitled);
  console.log((foo as unknown as Ref<typeof foo>).value.isEntitled);

Outputs:
CleanShot 2024-01-12 at 12 42 56

In this case, the user is indeed entitled, so true is the correct output.

Similar to #349

@hognevevle hognevevle added the bug Something isn't working label Jan 12, 2024
@doregg
Copy link
Contributor

doregg commented Jan 12, 2024

@hognevevle Thanks for reporting the issue. We will take a look and update.

@doregg
Copy link
Contributor

doregg commented Jan 15, 2024

Fixed in 3.0.14

@doregg doregg closed this as completed Jan 15, 2024
@hognevevle
Copy link
Author

Thanks @doregg , but it seems the typings disappeared after this change (now returning any instead). 🤔

CleanShot 2024-01-15 at 11 56 58
CleanShot 2024-01-15 at 11 56 14

npmjs.com confirms the same:

CleanShot 2024-01-15 at 11 58 12

@hognevevle
Copy link
Author

hognevevle commented Feb 28, 2024

@doregg Can you please reopen this? The types are still gone as of 3.0.19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants