'NuxtJS v2 check for typescript errors

I have a nuxt application with config like this

nuxt.config.js

...
  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/typescript
    '@nuxt/typescript-build',
  ],
...

When I have a typescript error in code, I got an error during yarn build

ERROR in pages/index.vue:31:12
TS2345: Argument of type 'number' is not assignable to parameter of type 'String'.
    29 |   created() {
    30 |     const x: Array<String> = []
  > 31 |     x.push(12)
       |            ^^
    32 |     alert(x[0])
    33 |
    34 |     successToast(this, 'Yeah!')

 FATAL  Nuxt build error                                                                                                                                                                         23:25:44

Now, I run yarn build command on CI to verify that code has no typescript errors. But build command takes a lot of time, and I want to improve CI speed.

How can I check for typescript errors in the way yarn build do it without actually running build?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source