I'm getting this error trying a simple jQuery sample with Typescript:
"tsc.js(23915, 17) Microsoft JScript runtime error: '$' is undefined"
My entire .ts file:
/// <reference path="scripts/jquery-1.8.d.ts" />
$(document).ready(function () {});
The jquery-1.8.d.ts is from DefinitelyTyped, but I get the same error if I use the standard jquery.d.ts. I'm not getting any errors on the reference tag, it's correct and is finding the .d.ts file.
I'm obviously missing something basic here, I can't figure out why I'm getting this error. I've got the VS 2012 extension installed and am getting full autocomplete on jQuery... so when I type '$' I do get autcomplete popups. The generated .js file is correct, nothing wrong there. A much more complex .ts file is compiling correctly and the output .js file is perfectly fine, so this is more of an annoyance than an error, I suppose. Or am I missing other errors because of this runtime error??
I'm compiling by adding an "External Tool" in VS with command: C:\Program Files (x86)\Microsoft SDKs\TypeScript\0.8.1.1\tsc.exe arguments: -e "$(ItemPath)" --sourcemap
I believe the issue is with the command that you are using itself, or at least one of the options you are passing in. "-e" tells the compiler to "Execute the script after compilation". So what you see, "Microsoft JScript runtime error: '$' is undefined", is not a compile error, but rather a runtime error that is showing up after the file is compiled and is in the process of being executed.
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With