lukejacksonn / oceanwind

Compiles tailwind shorthand into css at runtime. Succeeded by Twind.
https://twind.dev
264 stars 12 forks source link

Correct types for function call passing an array #46

Closed jamesb3ll closed 3 years ago

jamesb3ll commented 3 years ago

Function call passing an array like the example below, falsey items will be omitted, but the types don't reflect that (string[])

ow(['bg-red-500', false && 'rounded']);

I originally fixed this by making it accept Array<string | boolean>, although ow([true]) will result in "true".

I'm quite new to TS, but I guess to include all falsey values I could make it Array<string | false | "" | 0 | NaN | null | undefined>, but that seems too much and new falsey type could be added (eg. BigInt: !!0n === false).

Typescript normally prefers being explicit so consumers can convert falsey values to boolean (!!).

So Array<string | false> seems like the best solution.

Also, thanks for the great and interesting library, I used it to convert a CRA styled-components app to tailwind without having to set up all the tailwind processing, plus I'm not sure CRA supports Tailwind out-of-the-box.

lukejacksonn commented 3 years ago

Hey @jamesb3ll thanks for this, haven't kept tabs on this repo recently so apologies for the delay. This change seems reasonable. I am no typescript expert either 😅

Happy to merge here but not sure when I will get to publish. Did you know that the parent project of this exists https://twind.dev? It is a bit more mature and might suite your needs better.

Thanks again for the contribution.

jamesb3ll commented 3 years ago

Thanks for merging Luke! Looks like I already had Twind starred on GitHub but completely forgot about it, I'll check it out. Maybe add to top of the readme that Twind is the parent project and this is no longer maintained.