I have been attempting to get to know this new \'TypeScript\' stuff, and I am a bit curious on something.
Can it still work with existing javascript frameworks like jQuer
Yes you can. For example just write:
declare var $;
and you can basically use the JQuery framework without having to define anything else. This is also very handy when you are converting your existing libraries / porting code.
Typescript allows you to declare variables in the descired scope using the declare variable
or declare function
syntax (see Section 1.1 on page 9 in the language specification). However, using ambient declarations can only be a short-term solution since you will effectively loose all of Typescript's static type checking and hence one of the most important advantages of Typescript over Javascript.
The simple answer is yes.
TypeScript is able to interact fully with any existing Javascript library. You only need the definition file if you want tooling in the IDE to make it easier to use.
Also, if you don't include the definition file, the TypeScript compiler might get mad at you for using a variable that hasn't been defined in your code (like $
). To get around that you might have to do something like
declare var $;
That said, I'm not sure why you wouldn't want to use the jQuery definition file. It surely makes it much more pleasant to write jQuery with.