Skip to content

Handle unknown typehints #5588

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

Merged
merged 1 commit into from
Sep 24, 2021
Merged

Handle unknown typehints #5588

merged 1 commit into from
Sep 24, 2021

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Sep 24, 2021

This PR improves unnecessary typehints. If we know that only a single plugin is handling w in this case, then any typehints can be ignored because the contents of the arbitrary values can accept anything (due to the (default) any typehint).

input:

<div class="w-[length:12px]"></div>

output:

.w-\[length\:12px\] {
    width: 12px
}

However, this will also provide you with a warning in the terminal output:

warn - Unnecessary typehint `length` in `w-[length:12px]`.
warn - You can safely update it to `w-[12px]`.

We can remove warning if it is too much noise, but it is nice that we can detect this behaviour.
The current heuristic is to check whether only a single plugin exists that handles a certain prefix (w-).

@RobinMalfait RobinMalfait changed the title handle unknown typehints Handle unknown typehints Sep 24, 2021
If you use a typehint like `w-[length:12px]`, then currently that
wouldn't generate anything because we don't have a matchUtilities for
`w` with a `length` type. To fix this, we can detect if this is
unnecessary, if it is we still generate the expected outcome. (In this
case `width: 12px`) but we also warn to the user that we detected this.

Currently we detect this by checking if there is only a single plugin
registered for handling the prefix (e.g.: `w-`). We can probably improve
this by also checking all the types that all plugins are handling for
the resolved plugins.
@RobinMalfait RobinMalfait force-pushed the handle-unknown-typehints branch from 118e425 to 850a8b5 Compare September 24, 2021 16:22
@RobinMalfait RobinMalfait merged commit ab17c6c into master Sep 24, 2021
@RobinMalfait RobinMalfait deleted the handle-unknown-typehints branch September 24, 2021 16:28
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

Successfully merging this pull request may close these issues.

1 participant