1

I have a project with multiple typescript files. If I add a new typescript file I have to reference typings in order to compile it, VS couldn't resolve them itself. Also I have empty .ts file that doesn't require referencing typings, so I put code into it and it works.

When I found out it I kept the file and now when I need to create new .ts file, I copy that file and everything works like a charm.

So suppose in a folder I have two .ts files side by side: a copy of a magic file and a newly created one.

If I put this code in the magic file

class Test {
    test: KnockoutObservable<string>;
}

it compiles. If I put the same code into another file it says

Cannot find name KnockoutObservable

What is so special about the first file?

I'm using Visual Studio 2015. I have installed Knockout typings. I have empty tsconfig.json file in the solution. I don't want to reference typings using /// reference comment.

Thanks.

1 Answer 1

1

You need to use TSD and install appropriate ".d.ts" file, e.g. for knockout:

tsd install knockout

It downloads "knockout.d.ts" into your project and places definition into typings folder:

typings/knockout/knockout.d.ts 

Then you can add corresponding reference to the top or your "ts" file. e.g.:

/// <reference path="../../typings/knockout/knockout.d.ts" />
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.