Not compatible with nuxt 2.0.0

P4sca1
5
P4sca1
commented 3 months ago

Version

2.0.0

Reproduction link

https://github.com/nuxt-community/typescript-template

Steps to reproduce

vue init nuxt-community/typescript-template my-project
cd my-project
npm i -S [email protected]
npm install
npm run dev

What is expected ?

Working nuxt.js installation with TypeScript support.

What is actually happening?

TypeError: Cannot set property 'ts' of undefined
  at Builder.extendBuild.config (modules/typescript.js:24:33)
  at Builder.<anonymous> (node_modules/nuxt/dist/nuxt.js:155:17)
  at WebpackClientConfig.extendConfig (node_modules/nuxt/dist/nuxt.js:3126:56)
  at WebpackClientConfig.extendConfig (node_modules/nuxt/dist/nuxt.js:3258:26)
  at WebpackClientConfig.config (node_modules/nuxt/dist/nuxt.js:3164:33)
  at WebpackClientConfig.config (node_modules/nuxt/dist/nuxt.js:3292:26)
  at Builder.webpackBuild (node_modules/nuxt/dist/nuxt.js:3879:56)
  at Builder.build (node_modules/nuxt/dist/nuxt.js:3590:16)
  at <anonymous>
bug
0
Ataww
0
Ataww
commented 3 months ago

Have you tried following the migration guide here? https://github.com/nuxt/nuxt.js/releases/tag/v2.0.0

I changed the import/export style of the nuxt config file and typescript module and it worked.

0
P4sca1
5
P4sca1
commented 3 months ago

I changed
https://github.com/nuxt-community/typescript-template/blob/master/template/nuxt.config.js#L1 to
import parseArgs from 'minimist' and
https://github.com/nuxt-community/typescript-template/blob/master/template/modules/typescript.js#L1 to
export default function() {.
The result is the same. Am I missing something?

0
Ataww
0
Ataww
commented 3 months ago

module.exports at the bottom of nuxt.config.js need to be updated as well.

Here's how it looks like for me
https://github.com/Ataww/typescript-template/commit/703a522627740ce9e2af143cf40ea9d77f4a123d

edit: I found the missing bit. You also need to update the typescript module to include these changes https://github.com/nuxt-community/typescript-template/pull/47

0
P4sca1
5
P4sca1
commented 3 months ago

Your changes do not fix the issue for me. They just occur at a later state.
Updating ts-loader from 3.x to 5.x fixed the issue.

Also, do we really want to disable semantic checking, as it leaves us without type checking, which is basically the point of using typescript here, isn't it?

0
Ataww
0
Ataww
commented 2 months ago

Indeed, disabling type checking is not ideal unless you want to use the fork-ts-checker-webpack-plugin.

0
kazumatsudo
0
kazumatsudo
commented a month ago

I had the same issue and migrated like [email protected], but didn't work.
However, I fix the following and it worked.

// typescript.js
for (let rule of config.module.rules) {
  if (rule.loader === "vue-loader") {
    // add this line
    rule.options.loaders = rule.options.loaders || {};
    rule.options.loaders.ts = tsLoader;
  }
}

I think there may be a better solution.

version
nuxt: 2.2.0
ts-loader: 5.2.2

0
nicbavetta
0
nicbavetta
commented a month ago

Has anyone been able to successfully configure TypeScript into a Nuxt 2 project?

0
daveberning
10
daveberning
commented 17 days ago

Has anyone been able to successfully configure TypeScript into a Nuxt 2 project?

@nicbavetta I've created a class-based Nuxt 2.x starter template with TypeScript. I hope this helps!

0
daveberning
10
daveberning
commented 17 days ago

I've also created a pull request which also includes types and a strongly typed Vuex store.

0
AshleyCao
0
AshleyCao
commented 16 days ago

@kazumatsudo solution works for me

0
Informations
Bug Report โ€ข Open
#c44 - Created 3 months ago