Reputation: 37875
I would like to convert main.js file to TypeScript for learning purposes.
After having renamed the file to main.ts, I get a design time warning on this line:
define('knockout', ko); //Cannot find name define.
How do I resolve this warning?
Upvotes: 1
Views: 149
Reputation: 1732
You need to let TypeScript know about external libraries. The easiest way to do that is through DefinitelyTyped. This link will take you to the require.js deffinitions for TypeScript. A .d.ts file is used to let TypeScript know about the API available through a libary, more info here.
You can get any definitelyTyped definition files though nuGet in VisualStudio.
/// <reference path="../scripts/typings/requirejs/require.d.ts" />
In VS, you can drag and drop the d.ts file into the .tx file and it will create the above code for.
Upvotes: 3