-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
add hints to troubleshoot NextJS + TS issues. #2703
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsx jsxat the top of every file is not necessary to get Next, TypeScript, and Emotion to play nicely together, so I don't think we should recommend this to users. I rewrote the Emotion documentation site in Next & TypeScript (#2571) and got it to work withjsxImportSourceintsconfig.jsonand@emotion/babel-plugin— though I'm pretty sure the Babel plugin is not truly necessary here.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you!
I also find that instruction to "add this everywhere" a bit odd, and wholeheartedly agree with you about it... however, as you may realise, it is not part of my changes. As you will notice in the existing docs, they already had that statement before my PR.
In fact, I'm suggesting to modify "will need" to "may need", so it doesn't sound as mandatory.
I tried to change as little as possible in the existing verbiage, but you're right: that line needn't be added everywhere, and I'd like to improve that too.
Naturally, I'm willing to improve this PR if you can advise better phrasing for those other sentences/words I didn't add/change. Any suggestions? I'm also ok closing this PR if your rewrite handles the issue I had.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
side note, you mention you got it to work with just the babel plugin and jsxImportSource? for some reason I wasn't able to get css props going correctly until I also added the /// declaration.
will give your rewrite a good read, and maybe you'll let me pick your brain if I cannot manage to make it work that way?
edit: just went through your rewrite (awesome amounts of work, btw), and could not find any other differences in config, apart from the NextJS version itself (I'm on
^12.1.2). I wonder if that (or any other package's version difference) is what didn't let the css props work? 🤷Additionally, I see you're removing the pragma from all the docs, but I'm not sure I recall what you will recommend for people not using
babel(or the emotion babel plugin, for that matter)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @caravinci 😊
@jsx jsxfor all Next.js users.///declaration to get TypeScript to recognize thecssprop. I believejsxImportSourceintsconfig.jsonis all that's needed to tell TypeScript about the extra prop.@jsxpragma from all of the code samples because, some of those are live examples and the pragma was messing them up, and also I want the docs to be focused on thereact-jsxtransform which does not require the pragma.Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I'm not sure I would read it that way, I see what you mean and how others may indeed read it that way too. Those not using babel, in particular, may be led to misunderstand my changes.
Your comment makes sense to me now. Thanks for pointing that out 🙏
yeah, it seems reasonable to me too, but for some reason it didn't work in my project/setup. There may be something else going on here that's not obvious to me right now. I'll run some tests this weekend, see if I can at least figure out what the root issue is, and document it.
oh, that would be awesome, and very useful... especially as the NextJS team are actively working on better integration for their SWC. I will gladly help if possible, pending availability at my job, of course.
That said, this PR is not necessary.