Within my Aurelia View-Model, I am working on a Typescript file that contains the following structure:
import {Chart} from './chart';
interface IMargin {
top: number, right: number, bottom: number, left: number
}
export class App{
chartOptions: any;
constructor(margin: IMargin) { // No error here
this.chartOptions = {
element: "#chart",
margin: IMargin // Error: Cannot find name "IMargin"
};
}
attached() {
var chart = new Chart(this.chartOptions);
chart.addChart();
}
}
The Typescript compiler accepts using an interface in the constructor, but it throws an error Cannot find name "IMargin"
when attempting to define margin
within the constructor. Why does this occur?
In addition, where would be the most appropriate place to declare interfaces if the current method is incorrect? Thank you.