macaron-css / macaron

Compiler-augmented typesafe CSS-in-JS with zero runtime, colocation, maximum safety and productivity
https://macaron.js.org/
MIT License
735 stars 16 forks source link

Types not working for Solid #58

Closed aryzing closed 2 months ago

aryzing commented 3 months ago

Seems the types are not working for @macaron-css/solid v1.5.1. I'm not getting any intellisense with v1.5.1. Is there something missing here?

simplescreenrecorder-2024-03-24_19.54.20.webm

Mokshit06 commented 3 months ago

Ah yeah, the current SolidJS adapter doesn't have proper typings to support autocomplete, but it should be relatively easy to port over from React adapter. Can you open a PR doing that? If not, I will be able to fix it this week.

aryzing commented 3 months ago

Appreciate the encouragement, although I'm in the process of evaluating CSS libs and don't have the bandwidth to fix the issues I find with them

PalmDevs commented 2 months ago

Ah yeah, the current SolidJS adapter doesn't have proper typings to support autocomplete, but it should be relatively easy to port over from React adapter.

What types are currently missing? Maybe I can help.

Mokshit06 commented 2 months ago

Actually I was wrong. The types DO already work. @aryzing Can you try restarting your TS server maybe? A few more questions:

video

aryzing commented 2 months ago

I must be doing something wrong then, because the types are just now showing for me. Reproduction repo.

simplescreenrecorder-2024-04-12_16.50.51.webm

Mokshit06 commented 2 months ago

Found the issue! So the way macaron's solid and react adapter were implementing the type definitions was through vanilla-extract's internal types that were being accessed from the /dist directory of the package. This worked fine when "moduleResolution" in tsconfig.json was set to "node", but when it's set to latest versions like "bundler" or "nodenext", Typescript gives more importance to the "exports" in package.json, and vanilla-extract didn't export files from the /dist directory there.

Since the example you had was indeed using "bundler", Typescript wasn't able to source the internal type defs.

This has been fixed in v1.5.2 now! Macaron now implements the type defs by itself.

aryzing commented 2 months ago

That's great, thank you!

PalmDevs commented 2 months ago

@Mokshit06 Hi there, the issue seems to still be present in 1.5.2. For whatever reason, the published types still uses the wrong import in index.d.ts file, but not in index.d.mts file. Could you look into this?

The issue

Here's the link to the page.

I changed the import manually in my local installation, everything works fine after that.

Mokshit06 commented 2 months ago

Thanks for reporting this! Yeah I think I missed updating the exports in package.json to index.d.mts. Please update it to v1.5.3 :)