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
Next 13 - Using number constants for revalidate
value make TS complain in VS Code
#41951
Comments
revalidate
valuerevalidate
value make TS complain in VS Code
This is the correct behavior because these configurations should be statically analyzable (e.g. the compiler can know the information without executing the code). So things like That said, the error message isn't great and it should explain this better. We will improve that part for sure, thanks for opening this issue 👍 |
Thanks for the clarification @shuding! I think it would make sense to also mention that in the docs to prevent confusion :) |
I opened #42062 to improve it. |
…lly analyzable (#42062) As per #41951 (comment), this PR improves the TS plugin error message when a non-literal configuration is used: <img width="902" alt="CleanShot 2022-10-28 at 07 36 31@2x" src="https://user-images.githubusercontent.com/3676859/198650771-026a0430-d5bc-4826-9aef-b1bfb7947c6f.png"> Also a bug is fixed so string template literals (``const revalidate = `auto`;``) will no longer result in an error. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see `contributing.md` ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see `contributing.md` ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Verify canary release
Provide environment information
What browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
Describe the Bug
For some weird reason whenever I use a constant for
revalidate
parameter of a page component, I get a TS error in VS Code stating that this is an invalid value. It looks like it's validating agains the constant name and not the value.The app still runs and builds fine, and when running TSC manually, I don't get this error message.
Expected Behavior
revalidate
should support both passing arbitrary values and variables as long as their type is correct.Link to reproduction
https://stackblitz.com/edit/vercel-next-js-agx376
To Reproduce
Unfortunately I couldn't reproduce the issue on Stackblitz (maybe some VS Code settings are different), but the error message is definitely coming from the
next
typescript plugin, see this fileThe text was updated successfully, but these errors were encountered: