-
-
Notifications
You must be signed in to change notification settings - Fork 170
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
Typed classnames for autocompletion #15
Comments
I have an idea of how to support a typed API, but we have to migrate to TypeScript in that case. From TypeScript 2.9 you can import JSON modules in TS files with full typed support. We can create a |
@matepapp nice find! However, I can't think of a sensible TypeScript solution that would not require the API change I mentioned above. Your current implementation would only allow one className in the My proposal would look something like this: import JSON from "./styles.json";
type Keys = keyof typeof JSON;
const tailwind = (...props: Keys[]) => {
return props.reduce(
(styles, curr) => ({
...styles,
...JSON[curr],
}),
{}
);
} |
Yes, this was only just a quick example to demonstrate the possibility of type-safety. Your solution is definitely a step ahead, but I think we should support regular I might can create a draft pull request next week if it’s okay for you @vadimdemedes |
Well we could either add an additional function to the core or add readme instructions on how to achieve this with a custom tailwind function (would be neat if |
@matepapp Yeah, I think something like that would work. Would be still great to preserve support for specifying multiple classes in one string for people that don't care about autocomplete (like me). The only thing I'm wondering about is how will it work with custom configs? |
@vadimdemedes You may be interested in following this Tailwind Intellisense issue (https://github.com/tailwindcss/intellisense/issues/129) in regards to this. |
@tommulkins Thanks for linking it here! |
I think this might have just become more feasible with the improvements in TS 4.1 |
Is there a PR on the horizon for this? |
There is now a way to achieve this with the official VSCode extension. |
For those who want a quick copy and paste: "tailwindCSS.experimental.classRegex": ["tailwind\\('|\"([^'|\")]*)"] ^ add to your VS Code |
To make intellisense work in a tailwind-rn project, i.e.
|
I think we can close this issue 👍🏻 |
I must run |
Afaik you only need a tailwind.config.js in your project root for IntelliSense to work. |
You can run |
Seems you need to have it installed then. Note that the autocomplete will adhere to your tailwind configuration and not to |
this isn't working for me...i have pasted the above in setting.json My tailwind.js
My home.js
@tommulkins , @jonlambert or anyone could please resolve this |
I currently use tailwind-react-native-classnames with the following regex settings in my project: vscode/settings.json
I believe that last value in the array will do the trick, |
You need to open the VS Code setting file as a json. It should be under this Path (~/Library/Application Support/Code/User/settings.json) Then if you're using update the section of tailwind on your setting file as follows :
|
I like this API the most from the available Tailwind / RN projects but it's a bit sad to lose the ability for auto-completion.
What about going from this:
to something like this:
The text was updated successfully, but these errors were encountered: