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

Token autocompletion not working on utils [CodeSandbox] #291

Closed
hmbrg opened this issue Feb 18, 2022 · 22 comments · Fixed by #434 or #465
Closed

Token autocompletion not working on utils [CodeSandbox] #291

hmbrg opened this issue Feb 18, 2022 · 22 comments · Fixed by #434 or #465
Labels
🐛 Type: Bug Something isn't working

Comments

@hmbrg
Copy link

hmbrg commented Feb 18, 2022

Describe the bug
Autocomplete does not seem to work for utils right now. Inside of css() the utils are not even defined as a prop, they are only there if you create a media query with css({"bp1": {"pt": ...}}).

Steps to reproduce

  1. Use the css() or styled() function
  2. Don't get any autocompletion for utils

I've created a CodeSandbox here: https://codesandbox.io/s/distracted-rain-s63rmp?file=/src/App.tsx

Expected behaviour
I would expect to get suggestions of the available tokens.

@jrgarciadev
Copy link
Member

Thank you for reporting it @hmbrg 🙌🏻

@jrgarciadev jrgarciadev added ✨ Type: Enhancement New enhancement on existing codebase stitches labels Feb 19, 2022
@hmbrg
Copy link
Author

hmbrg commented Mar 10, 2022

Are there any updates on this? I would love to contribute a fix for this, but I've been looking into this issue and I have no idea what causes it. Do you have any clues on what might be the problem here?

The error even states that there is no utility registered. Installing vanilla stitches in the repo works just fine though.

Screenshot 2022-03-10 at 03 08 58

@jrgarciadev
Copy link
Member

Hey guys @hmbrg it seems that Stitches has a problem with the latest Typescript version stitchesjs/stitches#947

A user shared a temporal solution:
stitchesjs/stitches#947 (comment)

It was the way we solve it, hope it helps you

@hmbrg
Copy link
Author

hmbrg commented Mar 10, 2022

Thanks for your response! Unfortunately, that doesn't fix it, and the codesandbox I provided in the issue doesn't use an affected typescript version.

I've created a new codesandbox showing the issue next to the working "vanilla" stitches config: https://codesandbox.io/s/nextui-type-issue-5x128y?file=/pages/index.js

Looking at the type of px shows that all type information is missing. Also all the breakpoints etc. are missing from the styled() options, but it all works with the "vanilla" stitches config.
Screenshot 2022-03-10 at 14 16 14

@jrgarciadev
Copy link
Member

jrgarciadev commented Mar 10, 2022

Hey @hmbrg the commented solution aims to "VSCode", however, I was checking the CodeSandbox and is not a "Typescript" template, I've created a new Codesanbox base on the Typescript template and it works well,

Screenshot 2022-03-10 at 10 32 07

https://codesandbox.io/s/stitches-token-nextui-tzufq0?file=/src/App.tsx

It's also important to point out that is not a NextUI bug, we're waiting for the Stitches team to fix it as well

@jrgarciadev jrgarciadev added 🐛 Type: Bug Something isn't working and removed ✨ Type: Enhancement New enhancement on existing codebase labels Mar 10, 2022
@hmbrg
Copy link
Author

hmbrg commented Mar 10, 2022

I'm sorry to be such a bother, but even the example you shared doesn't seem to be working correctly. The type of px is still not set correctly, and I'm not getting any autocompletion on the token values that px accepts.

Screenshot 2022-03-10 at 14 38 20

@hmbrg
Copy link
Author

hmbrg commented Mar 10, 2022

In fact, I'm not getting any token completion on any CSS property, not only utils. This works when using Stitches on its own as shown in my second codesandbox.

@WonderPanda
Copy link

I'm very interested to try out Next UI as well but I've been getting really used to the level of typescript/intellisense integration provided natively by stitches. Not having access to type safety for the utils that NextUI adds to the stitches theme feels like a big loss here.

@jrgarciadev Looking at the sandbox link you've provided, there is no intellisense for any of the utils let alone enforcing the correct values are used with the util (eg px)

@jrgarciadev
Copy link
Member

Hey @WonderPanda I'm glad you want to use NextUI, the IntelliSense problems on CodeSandbox are caused due to is not possible to set a custom Typescript version at least up to now codesandbox/codesandbox-client#942, and Stitches has a problem with the latest Typescript version (which is used by CodeSandbox) stitchesjs/stitches#947 (comment), we hope they fix that issue soon in order to have IntelliSense also on CodeSanbox, btw if you use VsCode you will not have this issue at all so you can try out NextUI without problem 👍🏻

@jrgarciadev jrgarciadev changed the title Token autocompletion not working on utils Token autocompletion not working on utils [CodeSanbox] Mar 23, 2022
@jrgarciadev jrgarciadev changed the title Token autocompletion not working on utils [CodeSanbox] Token autocompletion not working on utils [CodeSandbox] Mar 23, 2022
@WonderPanda
Copy link

Hey @WonderPanda I'm glad you want to use NextUI, the IntelliSense problems on CodeSandbox are caused due to is not possible to set a custom Typescript version at least up to now codesandbox/codesandbox-client#942, and Stitches has a problem with the latest Typescript version (which is used by CodeSandbox) modulz/stitches#947 (comment), we hope they fix that issue soon in order to have IntelliSense also on CodeSanbox, btw if you use VsCode you will not have this issue at all so you can try out NextUI without problem 👍🏻

Thanks for super quick response! I'll try things out in VsCode

@hmbrg
Copy link
Author

hmbrg commented Mar 23, 2022

Hey @jrgarciadev, I'm sorry to chime in here again, but this is not working for me in VSCode either, even though we are not using the affected TypeScript version.

@jrgarciadev
Copy link
Member

Hey @hmbrg which Typescript version are you using? did you see this comment stitchesjs/stitches#947 (comment) ?

@hmbrg
Copy link
Author

hmbrg commented Mar 23, 2022

Yes, I did. We are using the recommended version of "4.5.5".

@jrgarciadev
Copy link
Member

@hmbrg Could you try using the v.4.3.4? which is the version NextUI is using https://github.com/nextui-org/nextui/blob/main/packages/react/package.json#L123

@hmbrg
Copy link
Author

hmbrg commented Mar 23, 2022

Here is a basic repo just like the CodeSandbox: https://github.com/hmbrg/nextui-autocomplete-issue/blob/main/pages/index.tsx#L7

The type of "p:" is of type p?: {} | undefined when I'm hovering over the property.

Changing the typescript version to 4.3.4 doesn't fix it, sadly.

@jrgarciadev
Copy link
Member

@hmbrg did you change also the vscode typescript version? or just the project version?

@hmbrg
Copy link
Author

hmbrg commented Mar 23, 2022

Yes, I made VSCode use the workspace version, not changing that makes the length error appear. After changing this the error goes away, but this issue persists.

The settings are set to: "typescript.tsdk": "node_modules/typescript/lib"

@jrgarciadev
Copy link
Member

Hey @hmbrg could you please check the version you are using is set as follows:
typescript": "4.3.2"

Notice that it has no the ^ symbol, otherwise could be being installed other minor typescript version

@hmbrg
Copy link
Author

hmbrg commented Mar 25, 2022

Just tried that, sadly it doesn't fix it for me. I updated my example repo here: https://github.com/hmbrg/nextui-autocomplete-issue/blob/main/pages/index.tsx#L7

Have you tried my repo? Does this work for you? If yes, maybe it's something else with my local setup.

@jrgarciadev
Copy link
Member

Hey @hmbrg I'm still trying to figure out why the Typescript/IntelliSense is not working on CodeSandbox, if you look at this example https://codesandbox.io/s/nextui-xxl-button-kbhbid?file=/App.js (Only JS) the autocomplete works 🤔

Regarding VsCode autocomplete it works for me here's a video (it's laggy because I tested it on Github Codespaces):
https://user-images.githubusercontent.com/30373425/160298712-05e37f88-99c6-41c3-bf7e-aa923436ff7d.mov

@hmbrg
Copy link
Author

hmbrg commented Mar 27, 2022

Thanks for looking into this! I've noticed, that even in the video you provided, the $black in bgColor: "$black" didn't autocomplete. The type overlay in VSCode even showed the type of bgColor as {} | undefined. I really wonder what's going on, because this defintly works with just using Stitches on its own, as you can see in this example: https://codesandbox.io/s/nextui-type-issue-5x128y?file=/pages/index.js

@stale stale bot added the type: stale label Apr 6, 2022
@stale stale bot removed the type: stale label Apr 6, 2022
@nextui-org nextui-org deleted a comment from stale bot Apr 6, 2022
@hmbrg
Copy link
Author

hmbrg commented Apr 11, 2022

Bump. Are there any news on this? I'm still trying to figure this out.

jrgarciadev added a commit that referenced this issue Apr 25, 2022
…tability

fix: #291 stitches compatability with typescript
@jrgarciadev jrgarciadev added this to the 🔥 v1.0.0-beta.7 milestone Apr 25, 2022
@jrgarciadev jrgarciadev linked a pull request May 9, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Type: Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants