wagerfield / nuxt-typescript

TypeScript module for Nuxt
MIT License
90 stars 11 forks source link

ts loader not worknig for server middleware? #14

Open sweetim opened 6 years ago

sweetim commented 6 years ago

I try to write a simple serverMiddlerware using a .ts, but it complains

interface Student {
            ^^^^^^^
  SyntaxError: Unexpected identifier

for reference my sample.ts file is below

interface Student {
    name: string
}

const a: Student = {
    name: 'hhehe'
}

console.log(a)

and in the nuxt.config.js, i set the serverMiddleware as below

serverMiddleware: [
  '~/api/sample.ts'
]

may I know how to resolve this problem?

wagerfield commented 6 years ago

@sweetim as per my comment in #15 I will be updating this module to support Nuxt 2.0 over the next few days, so I'll get back to you on this as and when I have done so.

sweetim commented 6 years ago

@wagerfield awesome!

this issue might be related to this https://github.com/nuxt/nuxt.js/issues/3948

JuniperChicago commented 5 years ago

I found setting "module": "es2015" in tsconfig.json worked for a typescript file. It compiles once, so in nuxt dev mode, serverMiddleware file changes will not hot-reload, but otherwise it seems to work for me.