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

feat: allow typescript compilation of nuxt.config #198

Closed
wants to merge 15 commits into from

Conversation

danielroe
Copy link
Member

@danielroe danielroe commented Nov 17, 2019

This PR allows typescript compilation of nuxt.config.ts, as well as serverMiddleware and local modules. When using this approach, @nuxt/typescript-runtime should only be required at build-time.

Rendered docs

TODO:

  • Create tests
  • Add documentation

@kevinmarrec kevinmarrec added feature Pull requests that implement a feature runtime The issue or pull request is related to `runtime` package labels Nov 20, 2019
@kevinmarrec
Copy link
Contributor

@danielroe Could you resolve conflicts ? Also what exactly did you succeed to achieve for now ?

@danielroe
Copy link
Member Author

danielroe commented Nov 30, 2019

@kevinmarrec I've edited the PR description explaining what it can currently do.

@danielroe
Copy link
Member Author

@kevinmarrec Okay, I've added tests and docs and think this is now ready for you to look at.

@HunderlineK
Copy link

Hey, I was following the guide for support typescript with serverMiddleware by using nuxt-ts generate but from this feature request it seems typescript for serverMiddleware for production is not supported yet?

I'm running into a bunch of syntax errors with nuxt-ts generate, but I suppose if the feature is not supported, those errors are also expected?

@HunderlineK
Copy link

HunderlineK commented Apr 10, 2020

So I solved my issue, in a way! I didn't manage to make typescript compiling work, but simply enabling the options "allowJs": true, and "checkJs": true provides you with errors in your editor (I use VS Code) even if the file extension is js. Then, you can just start typing your code using jsdoc and define your more complex types in a .d.ts file (I have multiple of those files for different domains in my app).

An advantage of defining types in a '.d.ts' file is that you can share them between your APIs and front end!

I am impressed by how great interoperability between jsdoc and typescript is; I have yet to come to a situation where I want to specify a certain type in jsdoc and I can't.

Having used this for a production app, I think this is even better than writing typescript files, because 1. you don't have to worry about any kind of compiling issues 2. your codebase remains clean JavaScript and 3. I find jsdocs to be necessary for certain functions and methods anyways

Hope it helps!

@TroyKomodo
Copy link

Is this dead?

@pi0
Copy link
Member

pi0 commented Jan 17, 2021

Starting with nuxt@2.15 we use jiti instead of esm as require engine which supports typescript-runtime out of the box.

@pi0 pi0 closed this Jan 17, 2021
@danielroe danielroe deleted the typescript-compile branch January 17, 2021 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Pull requests that implement a feature runtime The issue or pull request is related to `runtime` package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants