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

Automatically generate runtime config types from nitro.config the same as Nuxt #1706

Closed
1 task
McPizza0 opened this issue Sep 8, 2023 · 14 comments · Fixed by #2306
Closed
1 task

Automatically generate runtime config types from nitro.config the same as Nuxt #1706

McPizza0 opened this issue Sep 8, 2023 · 14 comments · Fixed by #2306
Labels
enhancement New feature or request

Comments

@McPizza0
Copy link
Contributor

McPizza0 commented Sep 8, 2023

Describe the feature

In Nuxt runtimeConfig keys/values are typed.
This improves DX considerably when accessing vis useRuntimeConfig()

Nitro has not yet implemented this, which can cause some confusion for users coming over from Nuxt

Result:
useRuntimeConfig() should be aware of the keys that exist in nitro.config.ts, and provide correct types

Additional information

  • Would you be willing to help implement this feature?
@algora-pbc
Copy link

💎 $20 bounty created by @McPizza0
👉 To claim this bounty, submit your pull request on Algora
📝 Before proceeding, please make sure you can receive payouts in your country
💵 Payment arrives in your account 2-5 days after the bounty is rewarded
💯 You keep 100% of the bounty award
🙏 Thank you for contributing to unjs/nitro!

@pi0 pi0 added enhancement New feature or request and removed pending triage labels Sep 8, 2023
@pi0
Copy link
Member

pi0 commented Sep 8, 2023

This is a good idea. As part of the implementation notes, I think we should enable it only by nuxi CLI as an opt-in flag to avoid conflicting with Nuxt types. /cc @danielroe

@mnmt7
Copy link

mnmt7 commented Sep 8, 2023

I would like to take a look at this.

@McPizza0
Copy link
Contributor Author

McPizza0 commented Sep 8, 2023

This would also help in nuxt when accessing runtime config from server side utils.

Currently when using useRuntimeConfig in a tRPC route, nothing is typed.

@rishi-raj-jain
Copy link

@McPizza0 @pi0 Can you help me point into the right direction?

@rishi-raj-jain
Copy link

/attempt #1706

@McPizza0
Copy link
Contributor Author

McPizza0 commented Sep 8, 2023

@rishi-raj-jain this may need input from @pi0 and @danielroe

I'm not sure how it was implemented in nuxt, but I would assume the solution will be fairly similar

Need to make sure it doesn't conflict with nuxt

@mnmt7
Copy link

mnmt7 commented Sep 8, 2023

@pi0 @McPizza0 @danielroe @rishi-raj-jain

Maybe we can use the TypeScript Compiler API to parse the configuration file and extract the types and then generate TypeScript definition files (.d.ts) based on the extracted types and apply the generated types.

@pi0
Copy link
Member

pi0 commented Sep 8, 2023

@ap172x
Copy link

ap172x commented Sep 26, 2023

@McPizza0 is this issue still open? @rishi-raj-jain are you still attempting this? I'd like to give it a try if you're not.

@rishi-raj-jain
Copy link

@ap172x sure go ahead.

@karthiknadar1204
Copy link

i'll try it

@oleksandr-shvets
Copy link

@ap172x @rishi-raj-jain @karthiknadar1204 can I take this?

/attempt #1706

@rishi-raj-jain
Copy link

rishi-raj-jain commented Feb 28, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants