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

Bitwise operator used in passthorugh/tailwind/index.js instead of logical operator #4415

Closed
tomaszpuzio opened this issue Sep 8, 2023 · 2 comments
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@tomaszpuzio
Copy link

Describe the bug

In /components/lib/passthrough/tailwind/index.js in lines 771 - 775 bitwise & operator is used instead of logical && operator.

{
    'text-gray-500 hover:bg-gray-300/20': props.plain & props.text,
    'text-gray-500 border border-gray-500 hover:bg-gray-300/20': props.plain & props.outlined,
    'text-white bg-gray-500 border border-gray-500 hover:bg-gray-600 hover:border-gray-600': props.plain & !props.outlined & !props.text
}

I believe this is a typo as also everywhere else in the file logical operators are used.
When trying to create custom button styling options, bitwise operator results in typescript error The '&' operator is not allowed for boolean types. Consider using '&&' instead..

I was not able to import PrimeVuePTOptions type in sandbox, therefore I did not add reproducer.

The proposed solution is to update bitwise & operator to logical && operator in the lines mentioned above.

Reproducer

no reproducer

PrimeVue version

3.34.0

Vue version

3.x

Language

TypeScript

Build / Runtime

Vue CLI App

Browser(s)

No response

Steps to reproduce the behavior

Create file e.g. example.ts :

import { type PrimeVuePTOptions } from 'primevue/config'

const example: PrimeVuePTOptions = {
  button: {
    root: ({ props, context }) => ({
      class: [
        {
          'text-gray-500 border border-gray-500 hover:bg-gray-300/20': props.plain & props.outlined,
        },
      ]
    })
  },
}

Expected behavior

No typescript error.

@tomaszpuzio tomaszpuzio added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Sep 8, 2023
@tomaszpuzio tomaszpuzio changed the title Bitwise & used in passthorugh/tailwind/index.js instead of logical && Bitwise operator used in passthorugh/tailwind/index.js instead of logical operator Sep 8, 2023
@tugcekucukoglu tugcekucukoglu added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible labels Sep 8, 2023
@tugcekucukoglu tugcekucukoglu added this to the 3.34.2 milestone Sep 8, 2023
@mertsincan
Copy link
Member

Opss! Good catch, we'll fix it asap. Thanks a lot for your report!

@tomaszpuzio
Copy link
Author

Thanks for such a prompt reaction! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

3 participants