Upon adding @types/uniqid using the command npm install --save @types/uniqid
to utilize in a class, I encountered an issue when trying to instantiate this class with new.
If I include
import uniqid = require("uniqid");
at the beginning of the page to use this.id = uniqid();
, it becomes impossible to create an instance of the class in the controller file (such as let movie = new Models.Movie();
).
If I omit 'uniqid'
, the controller file successfully locates the correct namespace Models
and class Movie
.
Does anyone have a solution for this? Thanks a lot!
Best regards
Code within Movie file
import uniqid = require("uniqid");
namespace Models {
export class Movie
{
id: string;
title: string;
poster: string;
constructor(title:string, poster:string, id?: string)
{
this.id = uniqid();
this.title = title;
this.poster = poster;
}
}
}
Code within Controller file
///<reference path="../Models/Movie.ts" />
///<reference path="../Contracts/IApiService.ts" />
///<reference path="../../Infrastructure/Api/Api.ts" />
namespace Controller {
export class MovieController implements Contract.ExternalApiData {
public ShowAllPopularMovies(data:any)
{
let movie = new Models.Movie('something','string'); // Issue here, controller file unable to find Movie class
}
}
}