-
-
Notifications
You must be signed in to change notification settings - Fork 305
using context with implicit vs explicit import #824
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
Comments
Hi @garrettladley thanks for the error report. This is expected as some of the imports being "magic" was causing a few issues and confusion, as well as making some logic a bit more complicated than it needed to be, so we have removed any standard library packages from being "magically" imported to templ files. I expect that the reason you are seeing an error in the LSP is that the templ binary that is being used as an LSP is different to the one you are using for But in short yes, this is expected. |
Hey @joerdav, thanks for getting back to me! Just for my understanding, when was this change made? I don't see anything mentioning context or imports in any of the recent changelogs. Also, I checked the docs before opening this issue and they didn't mention this change/new feature. The below linked pages about context still suggest using the implicit |
It was in the last release https://github.com/a-h/templ/releases/tag/v0.2.731 here's the commit: #793 It's maybe not obvious the side effects of this change, but since the formatter should fix any issues we accepted the risk. Absolutely happy to take a PR for clarifying the docs too :) |
this code that previously worked is now erroring on
templ generate
with reasonpath/to/file_templ.go:[line]:[col]: undefined: context
on my local i had been using v0.2.707, but, in my pipeline i was using a
go install github.com/a-h/templ/cmd/templ@latest
which at the time of writing this is v0.2.731(yes probably my fault to not update my local/pin my pipeline version)
original simplified example code:
in the fix, i simply import context. however, the LSP yells at me in the import statement saying
"context" imported and not used
and within Index it sayscontext redeclared in this block
.i'm fine with this fix since my templ generate and subsequent pipeline steps work again, was just wondering if this change was intended or is a regression
The text was updated successfully, but these errors were encountered: