-
Notifications
You must be signed in to change notification settings - Fork 375
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
[Bug?]: The example in the docs doesn't seam to work. #1466
Comments
I am going to ask for a reproduction. We have an example template https://github.com/solidjs/solid-start/blob/main/examples/experiments/src/entry-server.tsx#L4-L9 (the example uses an undeclared value, but switch it to n/s shows the right types). |
@ryansolid It does work if declared within entry-server.tsx. I created a repository based on a basic template. The types still don't work when declared within global.d.ts file. Look at the line 9 in the |
@RonenEizen for me it started to work also in the I am not sure why this is the case though. |
Oh.. hmm so this is a weird typescript-ism.. Lovely. Not sure what to do with this then. |
I think I got to the bottom of the behaviour, it is described here ambient vs augmented modules. Just adding an |
I am personally fine with the workaround. Should I keep this issue? Or would you rather have it resolved? |
@ryansolid i guess it would make sense to rework to namespace? i threw together the needed changes here #1469 -> than the new way to overwrite the
The old first line reference is not needed. |
I think the only thing needed to get the The schema documentation for package.json says:
Edit: For TypeScript <5 you may also need to add it to the Edit again: To clarify, I'm talking about the |
@rmacfie I did a couple of tests to figure it out and I did not test the specific suggestion. Did you test this? From my understanding the problem has nothing to do with the actual reference vs. import. Just TypeScript switching the module interpretation from |
Yes, I modified If I understand correctly, once |
@rmacfie can you share the test setup, i tried making the stated modifications but it does not work for me. |
I made a proof of concept of changes in solid-start and the basic example with some dummy extensions to the In console.log(import.meta.env.FOO);
console.log(requestEvent.locals.foo); The foo properties are typed according to the extensions declared in |
It may look weird but I believe this is the recommended pattern to follow for this situation. It has probably worked at some point without |
Yes that is working because adding an empty
The typescript docs state Honestly I have not seen/found a better option to fix this inconvenience than how i addressed it with the PR #1469 |
Duplicates
Latest version
Current behavior 😯
The example in the documentation doesn't seam to work.
locals
property within the RequestEvent doesn't have any types declared in global.d.ts. For example in one of the routes:and my global.d.ts has
Expected behavior 🤔
No response
Steps to reproduce 🕹
Steps:
event.locals.<SOMETHING>
within a route functionContext 🔦
No response
Your environment 🌎
No response
The text was updated successfully, but these errors were encountered: