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

Class Binding Type Missing #10866

Open
WORMSS opened this issue Nov 26, 2019 · 0 comments
Open

Class Binding Type Missing #10866

WORMSS opened this issue Nov 26, 2019 · 0 comments

Comments

@WORMSS
Copy link

@WORMSS WORMSS commented Nov 26, 2019

What problem does this feature solve?

When writing a computed property for a class binding, I found I couldn't type it for typescript.
I made a temporary one and remembered, there are more possibilities, so instead of writing them myself, I thought best to use the built in ones.
Yet I can't seem to find a built in one. Am I being really dense and they are actually there right in front of my nose and I can't see them?

At any rate, I have wrote my own as

export type VueClassBinding = string | readonly string[] | {
  readonly [className: string]: boolean,
};

Am I missing anything?
Is it possible someone can add this to the typings?

What does the proposed API look like?

...
computed: {
  inputClassList(): VueClassBinding {
    if ( Math.random() > .5 ) return 'my-class-name';
    if ( Math.random() > .5 ) return ['my-class-name'];
    return {
      'my-class-name': true,
    };
  }
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.