Skip to content

Class Binding Type Missing #10866

Open
Open
@WORMSS

Description

@WORMSS

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,
    };
  }
}
...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions