1

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?

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.