0

I wrote an interface that I want to use in my component. However, it seems like I can't really import the interface and I can't see the reason why.

Here's the important code:

My interface in src/types/Job.ts

interface Job {
  name: string,
  salary: string,
  isPopular: boolean
}

export default Job

And my App.vue setup function & import:

<script lang="ts">
import { defineComponent, ref } from 'vue'
import Job from './types/Job'

export default defineComponent({
  setup() {
    const jobs = ref<Job[]>([
      {
        ...
      },
      {
        ...
      }
    ])

    return { jobs }
  }
})

As an error I am getting the following:

Uncaught SyntaxError: The requested module '/src/types/Job.ts' does not provide an export named 'default' (at App.vue:55:8)

And I really wonder why or what is missing. Anyone an idea?

2
  • 1
    Try out import type Job from './types/Job' Commented Nov 7, 2022 at 12:32
  • Oh that worked, thanks! I was following a youtube tutorial that haven't added the "type" before in the import and it worked there. Really confusing but thanks! Commented Nov 7, 2022 at 12:37

1 Answer 1

1

Try out to add type after the import keyword :

import type Job from './types/Job'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.