nagiyevel
nagiyevel

Reputation: 424

Nuxt + TypeScript types not working in layouts and plugins

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

Upvotes: 2

Views: 1612

Answers (1)

Boussadjra Brahim
Boussadjra Brahim

Reputation: 1

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

 <script lang="ts">

Upvotes: 0

Related Questions