I know the question is already closed but I've found it searching for same TypeScriptException, maybe some one else hit this question searching for this problem.
The problem lays in missing TypeScript typing:
var coordinates = outerElement[0].getBBox();
Throws The property 'getBBox' does not exist on value of type 'HTMLElement'.
The easiest way is to explicitly type variable as `any`
var outerHtmlElement: any = outerElement[0];
var coordinates = outerHtmlElement.getBBox();
Edit, late 2016
Since TypeScript 1.6, the prefered casting operator is as
, so those lines can be squashed into:
let coordinates = (outerElement[0] as any).getBBox();
Other solutions
Of course if you'd like to do it right, which is an overkill sometimes, you can:
- Create own interface which simply extends
HTMLElement
- Introduce own typing which extends
HTMLElement
DEMO HERE
I prefer to have date objects, but as pointed out elsewhere, you can just convert to seconds if you want to do simple compares
function dateCompare(time1,time2) {
var t1 = new Date();
var parts = time1.split(":");
t1.setHours(parts[0],parts[1],parts[2],0);
var t2 = new Date();
parts = time2.split(":");
t2.setHours(parts[0],parts[1],parts[2],0);
// returns 1 if greater, -1 if less and 0 if the same
if (t1.getTime()>t2.getTime()) return 1;
if (t1.getTime()<t2.getTime()) return -1;
return 0;
}
alert(dateCompare("12:40:13","20:01:01"));
For seconds:
function dateDiff(time1,time2) {
var t1 = new Date();
var parts = time1.split(":");
t1.setHours(parts[0],parts[1],parts[2],0);
var t2 = new Date();
parts = time2.split(":");
t2.setHours(parts[0],parts[1],parts[2],0);
return parseInt(Math.abs(t1.getTime()-t2.getTime())/1000);
}
Assuming you have 24 hour times and same padding you can do simple string compare
var t1 = "12:40:13", t2= "20:01:01";
if (t1<t2) {
console.log(t1," is < ", t2);
}
Best Answer
The most likely reason for this is that you are using an older version of TypeScript than the definition author.
The language is moving swiftly and some of the features in version 1.4 are particularly useful in definition files, so it is likely that you will need to upgrade to 1.4 so that your machine can understand these new features.
Download version 1.4 here.