-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Putting a .ts file in middleware/ leads to death #2310
Comments
Can you have a look at: https://github.com/clarkdo/nuxt.js/tree/issue_2310/examples/typescript, it works for me, if anything I missed, pls tell me 😺 |
Hi @qm3ster In 1.0, we will remove native TS support, it will have to be used in with a module, so it will remove this unexpected behavior. |
@Atinux I'm using nuxt-ts-starter template and I do want my middleware as .ts files, I don't want to exclude them. How can I use them? I'm currently using 1.0.0-alpha.5 and still getting this error when I try to use .ts files inside middleware folder |
@AndrewBogdanovTSS are you up to date with https://github.com/nuxt/nuxt.js/blob/dev/examples/typescript/modules/typescript.js ? |
What do you mean by "up to date" ? I'm using latest CLI build of the ts starter template? Does it need any additional configurations to support .ts files? I thought that the whole intent of this template was to provide such functionality for users out of the box |
@qm3ster I've updated my modules/typescript.ts file to reflect the link you've sent, now I'm getting 2 errors: |
That's just node, you need to go higher in the call stack. |
There is no "higher" http://take.ms/Tv9Hz
|
I tried to debug it deeper but it's all buggy, fixing one issue reveals another one. Feels like it's not compatible with the setup used in Nuxt TS Starter |
Well, that's unhandled promise rejection for you! It turns men into vegetables and women into alcoholics. |
@AndrewBogdanovTSS, my duderino... modules: ['~/modules/typescript.js'], in It then started compiling my middleware and I was able to use it. |
Did you tried it on the version 1.0.0-alpha.5 ? It's the one that is used by the nuxt ts starter template |
Certainly not, there is no reason to use an alpha now that there's a release version. this.nuxt.options.extensions.push('ts')
//...
for (let rule of config.module.rules) {
if (rule.loader === 'vue-loader') {
rule.options.loaders.ts = tsLoader
}
} This is because the mechanism for adding custom script loaders wasn't fully extracted yet in that version. |
I'm all for it, but I'm just pointing out that I had to use alpha version because it was specified in the starter template and updating to new version manually was causing my app to crash. I've created a separate issue about that here: nuxt-community/typescript-template#24 |
- 現状 `.ts` ファイルは使用不可? [Putting a .ts file in middleware/ leads to death](nuxt/nuxt#2310)
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
nuxt
version:1.0.0-gh-704e7cd
If you put a
.ts
file inmiddleware/
whilenuxt dev
is running, everything is fine.Furthermore, this file is actually compiled as typescript and can be required on pages through the
middleware
property.However, if you stop the process and try to run
nuxt dev
again, you will get the most peculiar error:(only) page-level components (only) with
<script lang="ts">
will produce the following error:This happens for any
.ts
file in middleware and any<script lang="ts">
in a page, even if the middleware is empty and unused and the script tag is empty.The text was updated successfully, but these errors were encountered: