Smurfffy
Smurfffy

Reputation: 197

Importing a class with Typescript

I'm trying to import a class called review I have from another typescript file called review.ts into my review-service.ts file however I don't know why I'm getting an error but I don't think the review.ts file I have is being imported properly into the review-service.ts file.

The image below is the file with the error which outlines the path of the file I'm trying to import from and the file structure of the app

Screenshot 1

Also in another screenshot I have it shows the "module" for the path is coming up as *. I have no idea why this is an I've tried many different paths to try get this to work.

Screenshot 2

The constents of review.ts are as follows

  //review.ts
  export class Review {
    _id: number;
    description: string;
    isComplete: boolean;
  }

Upvotes: 11

Views: 34509

Answers (1)

Mateusz Szymik
Mateusz Szymik

Reputation: 204

import {Review} from '../app/review'

instead of

import {Review} from '../app/review.ts'

That's all :)

Upvotes: 12

Related Questions