0

I'm beginner with TypeScript, and I have one very simple problem. I'm trying to import file, so I could import interface. For example:

Parent:

import { User } from "@/Users";
    
export interface Gift {
  id: number;
  user: User;
  created_at: Date,
  updated_at: Date
}

Child (User.ts):

export interface User {
    id: string;
    first_name: string,
    last_name: string,
    email: string,
    created_at: string,
    updated_at: string
}

So it's giving error

File 'somepathhere/Users.ts' is not a module

In my case, Users.ts has only this interface, and nothing else, but parent component has some functions, but it's using User interface only this time.

4
  • 3
    Your import references Users but the file name is User (singular) Commented Sep 20, 2021 at 11:43
  • the import looks strange: did you mean ./user? Commented Sep 20, 2021 at 11:43
  • It's not about file name, it's actually correct in code Commented Sep 20, 2021 at 11:49
  • Well it depends what pathname the actual error references, most likely that will give us a clue as to what exactly is going wrong Commented Sep 20, 2021 at 11:56

1 Answer 1

1

The import statement should be import {User} from './User'

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.