Nuxt + TypeScript types not working in layouts and plugins

Viewed 1121

I'm new in TS and I want to use types in layouts too but as in the picture typescript-build returns error "Syntax Error: Unexpected token" when I add type to popups property.

In pages it works correctly. It's not working in layout and in plugins ts files.

Simplified not working VUE file is below.

<template>
  <div id="wrapper" class="d-flex no-gutters">
    <Nuxt/>
  </div>
</template>
<script type="ts">
import {Component, Vue} from 'nuxt-property-decorator'

@Component()
export default class Default extends Vue {
  popups: {
    [key: string]: {
      show: boolean,
      loading: boolean,
      changed: boolean,
      submit_loading: boolean
    }
  } = {
    login: {
      show: false,
      loading: false,
      changed: false,
      submit_loading: false
    }
  };
}
</script>

Syntax Error: Unexpected token

1 Answers

Your script should have the value ts for the lang attribute :

 <script lang="ts">
Related