nuxt / typescript

TypeScript Support for Nuxt 2
https://typescript.nuxtjs.org
MIT License
571 stars 124 forks source link

I got TS error, but nuxt is not breaking the build #593

Closed buglavecz closed 1 year ago

buglavecz commented 1 year ago

Describe the bug We want use nuxt 2 with typescript support, but I don't understand why don't break the build, if the TS code is bad?

Screenshots image

Additional context I tried add the --fail-on-error flag to package.json, but not working.... 🤔

"scripts": {
    "dev": "cross-env BUILD_VER=dev-local.0123456 COMMIT_HASH=0123456 nuxt --fail-on-error",

Thanks.

buglavecz commented 1 year ago

I seems this error come only if I use composition API, and script setup syntax.

rchl commented 1 year ago

Maybe it's an issue with your editor's Vue integration? I suppose it's not Volar or Vetur but maybe Jetbrains own one? I don't have experience with that.

buglavecz commented 1 year ago

Yes, jetbrain IDE . But I tried with script setup syntax and setup() function. With setup() function working fine, but with script setup no. I saw, the examples also use setup() function...

rchl commented 1 year ago

If you provide a repo I can try and see if I can reproduce. But again, if Nuxt and Volar doesn't complain then it sounds like an issue with Editor integration that does the type checking.

buglavecz commented 1 year ago

With this syntax setup syntax...

<template>
  <b-container class="mt-3">
    <h3>Composition API</h3>
    {{ fruit }}
  </b-container>
</template>

<script lang="ts">
    import { defineComponent } from 'vue';
    export default defineComponent({
        setup () {
            interface Apple {
                id: number,
                name: string,
                weight?: number
            }

            const fruit:Apple[] = [
                {
                    id: '10',
                    name: 'jonatan'
                },
                {
                    id: 20,
                    name: 'golden'
                }
            ];
            return { fruit };
        }
    });
</script>

I got this TS error in terminal: image

But, If I use Githubissues.

  • Githubissues is a development platform for aggregating issues.