Rade Iliev
Rade Iliev

Reputation: 229

TypeScript file is not a module

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.

Upvotes: 0

Views: 1966

Answers (1)

Nhan Tran
Nhan Tran

Reputation: 11

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

Upvotes: 1

Related Questions