error message
Compile Error.
See error list for details
…/Scripts/gallery.ts(13,15): The name ‘Size’ does not exist in the current scope
gallery.ts
/// <reference path="jquery.d.ts" />
/// <reference path="jquery.custom.js" />
(function ($) {
var $body = $(document.body);
var $win = $(window);
var animTime = 1000;
var $cg = $('#control_grid').data('flash', false);
function fitImage(img, max, enlarge) {
var ratio = Math.max(img.width / max.width, img.height / max.height);
if (ratio < 1 && !enlarge) ratio = 1;
return Size(Math.round(img.width / ratio), Math.round(img.height / ratio));
}
...
jquery.custom.js
function Size(w, h) {
return {
'width': w,
'height': h
};
}
...
question
When I mouse over “Size” in gallery.ts in Visual Studio it pulls up the correct definition, so clearly it can find the function. Why is the TS compiler giving me this error then?
The Size() function is at root level in jquery.custom.js, it should have global scope, no?
You won’t get type information by referencing a JavaScript file. You could either write that function in TypeScript, or create a definition file for it, i.e.
jquery.custom.d.ts.