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

Add isShown to TypeScript annotations #610

Closed
CodeF53 opened this issue Aug 23, 2023 · 4 comments
Closed

Add isShown to TypeScript annotations #610

CodeF53 opened this issue Aug 23, 2023 · 4 comments

Comments

@CodeF53
Copy link

CodeF53 commented Aug 23, 2023

Is your feature request related to a problem? Please describe.
I use the isShown attribute of my viewer to disable my programs hotkeys while the viewer is open:

function hotkey(e: KeyboardEvent) {
  // disable hotkeys while viewer is open
  if (viewer.isShown)
    return

  const { key, ctrlKey, shiftKey } = e
  ...

But typescript thinks isShown isn't a value on viewer, despite it being one.

Property 'isShown' does not exist on type 'Viewer'

Describe the solution you'd like
When it comes to variables that could be useful to people, like isShown add them to TypeScript annotations

Describe alternatives you've considered
If you don't want people writing to them, mark them private and add getters so we can still use them in a readonly manner (ie: getIsShown())

@fengyuanchen
Copy link
Owner

The isShown property of the viewer instance is an internal property, not a public property. If you still want to use it, try (viewer as any).isShown please.

@CodeF53
Copy link
Author

CodeF53 commented Aug 25, 2023

Can you give a good reason for why you can't give us a getter like getIsShown()?

as any is severe malpractice.

@CodeF53
Copy link
Author

CodeF53 commented Aug 28, 2023

Can you give a good reason for why you can't give us a getter like getIsShown()?

as any is severe malpractice.

@fengyuanchen

@fengyuanchen
Copy link
Owner

There are too many internal properties (about 30). I don't think it is a good idea to expose any one of them as they may be changed later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants